#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
// 파라미터로 주어지는 문자열은 const로 주어집니다. 변경하려면 문자열을 복사해서 사용하세요.
bool solution(const char* s) {
//기본 true 값
bool answer = true;
//count값
int countA = 0;
int countB = 0;
//문자열을 비교하고 카운트 한다
for(int i = 0; i < strlen(s); i++)
{
if(s[i]=='(')
countA++;
else
countB++;
//')'가 애초에 많으면 false 임
if(countB > countA)
{
answer = false;
break;
}
}
if(answer && countA == countB)
answer = true;
else
answer = false;
return answer;
}
'코테 좀 해라★彡 > C++' 카테고리의 다른 글
숫자의 표현 (0) | 2024.04.01 |
---|---|
이진 변환 반복하기 (1) | 2024.03.28 |
최솟값 만들기 (0) | 2024.03.25 |
JadenCase 문자열 만들기 (2) | 2024.03.25 |
최댓값과 최솟값 (0) | 2024.03.25 |
댓글