274. 문자열 내 p와 y의 개수

김해준's avatar
Jan 15, 2026
274. 문자열 내 p와 y의 개수

사용언어 : Java

문제
notion image
풀이
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; } }
notion image
Share article