올바른 괄호1 [프로그래머스][C++][2단계] 올바른 괄호 #include #include using namespace std; bool solution(string s) { bool answer = true; int count = 0; for(int i = 0; i 0) answer = false; return answer; } 1. '('와 ')'의 갯수를 세서 같은 경우에만 올바른 것이므로 해당 경우를 찾아야한다. 2. 먼저 갯수를 셀 count 변수를 선언하고, 문자열 s를 반복하여 각 문자들을 탐색한다. 3. 문자가 '(' 인 경우는 count를 증.. 2023. 11. 1. 이전 1 다음