// 문자열 내 p와 y의 개수 - 연습문제
public class CountStrPY {
boolean solution(String s) {
s = s.toLowerCase();
int yCount = 0, pCount = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == 'p') {
pCount++;
}
if (s.charAt(i) == 'y') {
yCount++;
}
}
return pCount == yCount ? true : false;
}
public static void main(String[] args) {
CountStrPY c = new CountStrPY();
String s1 = "pPoooyY";
String s2 = "Pyy";
System.out.println(c.solution(s1));
System.out.println(c.solution(s2));
}
}