๋ชฉ๋กcomponents (2)

Focus On Develop ๐ŸคŸ๐ŸคŸ

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ๋ฌธ์ž์—ด ๋‚ด p์™€ y์˜ ๊ฐœ์ˆ˜

๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„์—†์ด p์™€ y๋ฅผ ์ฐพ์•„์•ผ ํ•˜๋ฏ€๋กœ, s๋ฅผ ์†Œ๋ฌธ์ž๋‚˜ ๋Œ€๋ฌธ์ž๋กœ ๋ณ€๊ฒฝํ•œ ํ›„์— ์นด์šดํŠธ๋ฅผ ํ•˜๋ฉด ๋˜๋Š” ๊ฐ„๋‹จํ•œ ๋ฌธ์ œ๋‹ค! func solution(_ s:String) -> Bool { let string = s.lowercased() let pCnt = string.filter { $0 == "p" }.count let yCnt = string.filter { $0 == "y" }.count return pCnt == yCnt } ์‚ฌ์‹ค ๋‚˜๋Š” ํ•œ์ค„๋กœ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ์ฝ”๋“œ๋„ ์ด๋ ‡๊ฒŒ ๋ณ€์ˆ˜๋ฅผ ํ•˜๋‚˜ ํ•˜๋‚˜ ์ƒ์„ฑํ•˜๋Š”๋ฐ ์ต์ˆ™ํ•ด์ ธ์žˆ๋‹ค.(์žฌ์‚ฌ์šฉ ๊ฐ€๋Šฅ์„ฑ์ด ์—†๋‹ค๋ฉด ๋ฉ”๋ชจ๋ฆฌ ๊ณ ๋ คํ–ˆ์„๋•Œ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ƒ์—์„œ ๋ณ€์ˆ˜ ์„ ์–ธ์€ ์ตœ์†Œ๋กœ ํ•˜๋Š”๊ฒŒ ์ข‹๊ธด ํ•˜๊ฒ ๋‹ค.) ์—…๋ฌด๋ฅผ ํ•˜๋‹ค๊ฐ€ ์Šต๊ด€์ด ๋˜๋ฒ„๋ฆฐ.. ๐Ÿ˜ญ ๐Ÿ˜ญ ์•„๋ฌดํŠผ ์ด๋ ‡๊ฒŒ ํ’€๊ณ  ๋‹ค๋ฅธ ์‚ฌ๋žŒ์˜ ํ’€์ด๋ฅผ ๋ดค๋Š”๋ฐ, S..