사용언어 : Java
문제

풀이
class Solution {
boolean solution(String s) {
s = s.toLowerCase();
int pCount = 0;
int yCount = 0;
for(int i = 0 ; i < s.length(); i++)
{
String temp = "";
temp += s.charAt(i);
if(temp.equals("p")) pCount++;
if(temp.equals("y")) yCount++;
}
if(pCount == 0 && yCount == 0)return true;
if(pCount != yCount)return false;
else return true;
}
}
Share article