개인공부/코딩연습
문자열 내 p와 y의 개수
NIGHT_LOVE
2020. 6. 21. 14:46
class Solution {
boolean solution(String s) {
String a[] = s.split("");
int countp = 0;
int county = 0;
for (int i = 0; i < a.length; i++) {
if (a[i].equals("P") || a[i].equals("p")) {
countp++;
}
if (a[i].equals("Y") || a[i].equals("y")) {
county++;
}
}
if (countp == county) {
return true;
} else
return false;
}
}