p와 y 개수에 따른 결과를 리턴해주면 되는 문제이다. 간단하다.
#include <string>
using namespace std;
bool solution(string s) {
int answer = 0;
for (auto c : s) {
if (tolower(c) == 'p') answer++;
else if (tolower(c) == 'y') answer--;
}
return !answer;
}