Skip to content

[WEEK09] 최준호#40

Merged
raejun92 merged 1 commit into
mainfrom
raejun
Apr 10, 2026
Merged

[WEEK09] 최준호#40
raejun92 merged 1 commit into
mainfrom
raejun

Conversation

@raejun92
Copy link
Copy Markdown
Collaborator

@raejun92 raejun92 commented Apr 5, 2026

이렇게 풀었어요

1. JadenCase 문자열 만들기

  • 문제를 풀었어요.
  • 풀이 시간 : 21분

1) 복잡도 계산

  • 시간 복잡도: O(n)
  • 공간 복잡도: O(n)

2) 접근 아이디어

  1. 문자열을 공백으로 분리해서 배열로 만들고, 배열의 요소들을 순회하면서, 각 요소의 첫 번째 문자가 숫자인지 확인했다.
  2. 만약 첫 번째 문자가 숫자라면, 해당 요소를 소문자로 변환해서 반환했다.
  3. 만약 첫 번째 문자가 숫자가 아니라면, 해당 요소를 소문자로 변환한 뒤에, 첫 번째 문자를 대문자로 변환해서 반환했다.
  4. 마지막으로, 배열의 요소들을 공백으로 연결해서 반환했다.

3) 회고

숫자인지를 확인하는 과정에서 문자열 숫자를 판단해야 되는데 숫자를 판단하고 있었다. 또한, split(' ')으로 나누면 맨 앞이 공백이 될 수 있다는 것을 간과하여 시간이 오래 걸렸다. 맨 앞이 숫자거나 문자거나 상관없이 대문자로 만들어도 문제가 없을 것 같다.



2. 올바른 괄호

  • 문제를 풀었어요.
  • 풀이 시간 : 9분

1) 복잡도 계산

  • 시간 복잡도: O(n)
  • 공간 복잡도: O(1)

2) 접근 아이디어

  1. 문자열을 순회하면서, "("가 나오면 score를 1 증가시키고, ")"가 나오면 score를 1 감소시켰다.
  2. 만약 score가 음수가 되는 경우에는 false를 반환했다.
  3. 문자열을 모두 순회한 후에는 score가 0인지 확인해서, 0이면 true를 반환하고, 그렇지 않으면 false를 반환했다.

3) 회고

기존에 풀이 방법을 암기하고 있어서 쉽게 떠올릴 수 있었다. 보통 stack을 이용해서 풀이하는 방법이 있지만, 효율성 면에서 score를 이용해서 풀이하는 방법이 더 좋은 것 같다.



3. 최댓값과 최솟값

  • 문제를 풀었어요.
  • 풀이 시간 : 7분

1) 복잡도 계산

  • 시간 복잡도: O(n)
  • 공간 복잡도: O(n)

2) 접근 아이디어

  1. 문자열을 공백으로 분리해서 배열로 만들고, 배열의 요소들을 숫자로 변환했다.
  2. Math.min과 Math.max를 사용해서 배열에서 최솟값과 최댓값을 구했다.
  3. 마지막으로, 최솟값과 최댓값을 문자열로 변환해서 공백으로 연결해서 반환했다.

3) 회고

정답률이 높은 순으로 풀다 보니 초반 문제는 쉽게 풀 수 있을 것 같다. 후반으로 갈수록 점점 더 어려워질 텐데 걱정이다. 쉬운 문제와 어려운 문제를 섞어서 풀어야 할지 고민이 된다.



Copy link
Copy Markdown
Collaborator

@LeeBaeJin LeeBaeJin left a comment

Choose a reason for hiding this comment

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

수고많으셨습니다!

Comment thread raejun/올바른괄호.js
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

index 변수를 하나 더 두어 while 문으로도 처리할 수 있군요. 제가 for문만 자주 사용하는 편인데 유연한 사고를 배우게 되었습니다!

Copy link
Copy Markdown
Collaborator

@sik9252 sik9252 left a comment

Choose a reason for hiding this comment

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

이번주도 고생하셨습니다!

Comment thread raejun/올바른괄호.js
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

저도 다음에 비슷한 문제 나오면 증감 방식으로 푸는 방법도 기억하고 적용해봐야겠어요!

Copy link
Copy Markdown
Member

@doitchuu doitchuu left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 👍

Comment thread raejun/올바른괄호.js
}

return score === 0 ? true : false;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

스택 말고도 증감식으로 카운팅하는것도 좋은 거 같아요 👍

@raejun92 raejun92 merged commit 44906f3 into main Apr 10, 2026
1 check passed
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.

4 participants