프로그래머스 12916 문자열 내 p와 y의 개수

1 개요[ | ]

프로그래머스 12916 문자열 내 p와 y의 개수

2 C++[ | ]

#include <string>
#include <iostream>
using namespace std;

bool solution(string s)
{
    int p = 0;
    int y = 0;
    for(const char& c: s) {
        if(c == 'p' || c == 'P') {
            p++;
            continue;
        }
        if(c == 'y' || c == 'Y') {
            y++;
            continue;
        }
    }
    return p == y;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}