Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PGS]괄호 변환 / level2 / 60분 / O #372

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ahyun39
Copy link
Contributor

@ahyun39 ahyun39 commented Jun 16, 2024

📖 문제

  • 프로그래머스 - 괄호 변환

💡 풀이 방식

is_right(p)

  • 올바른 괄호 문자열인지 확인하는 함수

divide(p)

  • 문자열을 두 "균형잡힌 괄호 문자열" u, v로 분리하는 함수

solution(p)

문제에 나와있는 "올바른 괄호 문자열"로 변환하는 방식을 그대로 구현했다.

  1. p가 빈 문자열이거나 올바른 괄호 문자열인 경우 p를 리턴한다.
  2. 문자열을 u, v 로 분리한다.
  3. u가 올바른 괄호 문자열인 경우 u + solution(v) 로 v에 대해 1단계부터 다시 수행하여 수행한 결과를 u에 이어 붙여서 반환한다.
  4. u가 올바르지 않은 문자열인 경우 문제에 나오는 4-1 ~ 4-5 과정을 통해 문자열을 생성한다.

🤔 어려웠던 점

x


❗ 새로 알게된 내용

x

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.

1 participant