Skip to content

Conversation

@Mordiumaco
Copy link
Collaborator

만약 자료구조를 사용했으면... 아마 STACK 이 제일 무난했을 것 같기는 한데
저 같은 경우는
제약사항을 기준으로 문제 풀이의 접근을 해봤습니다.

  1. ')' 이 먼저오면 쌍을 이루는 올바른 괄호는 만들어 지지 않는다.
  2. 그 이후에는 '('의 갯수와 ')'의 갯수가 같아야 한다.

위의 제약 기준만 지키면 나름 다가가기가 생각보다는 쉬운 문제였던 것 같습니다.

Copy link
Collaborator

@whdgns5059 whdgns5059 left a comment

Choose a reason for hiding this comment

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

깔끔하네요
저는 stack을 이용해 풀었는데 효율성테스트에서 실패해서
괄호의 개수를 새는식으로 바꿨어요

Copy link
Collaborator

Choose a reason for hiding this comment

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

3항 연산자의 결과가 boolean 타입이면 그냥 조건식을 return 해도 됩니다.
return stack == 0;

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