Skip to content

Conversation

ChangZero
Copy link
Member

문제 설명

괄호가 바르게 짝지어졌다는 것은 '(' 문자로 열렸으면 반드시 짝지어서 ')' 문자로 닫혀야 한다는 뜻입니다. 예를 들어

  • "()()" 또는 "(())()" 는 올바른 괄호입니다.
  • ")()(" 또는 "(()(" 는 올바르지 않은 괄호입니다.

'(' 또는 ')' 로만 이루어진 문자열 s가 주어졌을 때, 문자열 s가 올바른 괄호이면 true를 return 하고, 올바르지 않은 괄호이면 false를 return 하는 solution 함수를 완성해 주세요.

제한사항
  • 문자열 s의 길이 : 100,000 이하의 자연수
  • 문자열 s는 '(' 또는 ')' 로만 이루어져 있습니다.

입출력 예
s answer
"()()" true
"(())()" true
")()(" false
"(()(" false
입출력 예 설명

입출력 예 #1,2,3,4
문제의 예시와 같습니다.

Copy link
Collaborator

@LHyunn LHyunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코멘트 달았습니당.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 count가 한번이라도 -1로 가면 바로 False 리턴하도록 짰습니다.
어차피 )가 ()쌍이나 ( 앞에 하나라도 있으면 False기 때문에...
그래도 답엔 이상없으니 괜찮은듯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants