boolean solution(String s) {
int num = 0;
for (int i = 0; i < s.length(); i++) {
char c = Character.toLowerCase(s.charAt(i));
if (c == 'p') {
num++;
} else if (c == 'y') {
num--;
}
}
return num == 0;
}
출처:https://school.programmers.co.kr/learn/courses/30/lessons/12916