728x90
SMALL

class Solution {
boolean solution(String s) {
int pCount = 0, yCount = 0;
String[] array = s.toLowerCase().split(""); //소문자로 바꾸고 잘라 배열에 넣음

for (int i = 0; i < array.length; i++) 
{
    if ("p".equals(array[i])) 
    { 
        pCount++;
    } 
    else if ("y".equals(array[i])) 
    {
        yCount++;
    }
}
        
if (pCount != yCount) 

{
    return false;
}
return true;
}
}

728x90

설정

트랙백

댓글