func solution(_ s:String) -> Bool {
var answer: Bool = false
var pCount = 0
var yCount = 0
for character in s {
if character == "p" || character == "P" {
pCount += 1
}else if character == "y" || character == "Y" {
yCount += 1
}
}
if pCount == yCount {
answer = true
}
return answer
}
func solution(_ s:String) -> Bool {
return s.lowercased().filter { $0 == "p" }.count == s.lowercased().filter { $0 == "y" }.count
}
와 고차함수... 대단하십니다..