Skip to content

[WEEK09] 이지현#41

Merged
sik9252 merged 3 commits into
mainfrom
sik9252
Apr 9, 2026
Merged

[WEEK09] 이지현#41
sik9252 merged 3 commits into
mainfrom
sik9252

Conversation

@sik9252
Copy link
Copy Markdown
Collaborator

@sik9252 sik9252 commented Apr 7, 2026

이렇게 풀었어요

1. 최댓값과 최솟값

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

1) 복잡도 계산

시간 복잡도: O(n log n)

공간 복잡도: O(n)


2) 접근 아이디어

이 문제는 문자열로 주어진 숫자들을 공백 기준으로 나눈 뒤, 최솟값과 최댓값을 찾아 "최솟값 최댓값" 형태로 반환하는 문제이다. 배열로 만든 뒤 정렬해서 양 끝 값을 사용하면 쉽다.


2. JadenCase 문자열 만들기

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

1) 복잡도 계산

시간 복잡도: O(n)

공간 복잡도: O(n)


2) 접근 아이디어

이 문제는 문자열에서 각 단어의 첫 글자만 대문자로 바꾸고, 나머지는 소문자로 만들어 JadenCase 형태로 반환하는 문제이다.

capitalize라는 보조 함수를 만들어, 각 문자열에 대해 첫 글자는 대문자로, 나머지는 소문자로 변환하도록 했다. 이후 입력 문자열을 공백 기준으로 나누고, 각 단어에 capitalize를 적용한 뒤 다시 하나의 문자열로 합쳐 결과를 만들었다.


3. 올바른 괄호

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

1) 복잡도 계산

시간 복잡도: O(n)

공간 복잡도: O(n)


2) 접근 아이디어

이 문제는 문자열에 포함된 괄호가 올바르게 짝지어져 있는지 확인하는 문제이다. 괄호 문제는 가장 최근에 열린 괄호를 먼저 닫아야 하므로, 처음부터 스택을 사용하는 방식이 자연스럽게 떠올랐다.

그래서 문자열을 왼쪽부터 순회하면서 ( 이면 스택에 넣고, ) 이면 스택에서 하나를 꺼내는 방식으로 접근했다. 순회가 끝났을 때 스택이 비어 있으면 모든 괄호가 짝지어진 것이고, 비어 있지 않으면 올바르지 않은 괄호 문자열이라고 판단하도록 구현했다.

@github-actions github-actions Bot requested review from doitchuu and raejun92 April 7, 2026 09:15
@doitchuu doitchuu requested a review from LeeBaeJin April 8, 2026 15:16
Copy link
Copy Markdown
Collaborator

@raejun92 raejun92 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다~

Comment on lines +5 to +11
for (let i = 0; i < s.length; i++) {
if (stack.length === 0 || s[i] === "(") {
stack.push(s[i]);
} else {
stack.pop();
}
}
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
Collaborator

Choose a reason for hiding this comment

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

깔끔하군요!

let word = [];

s = s.split(" ");
s.map((e) => word.push(capitalize(e)));
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.

map을 쓰셔서 뭔가 리턴하시려나보다 생각해서 변수를 빠뜨렷나 싶었어요ㅠ
forEach를 사용하면 오해가 없어질 것 같아요ㅎ


s = s.split(" ");
s.map((e) => word.push(capitalize(e)));
answer = [...word].join(",").replaceAll(",", " ");
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.

join에서 바로 (" ") 요거는 안되는 건가요?!

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.

확실히 내장 함수 사용에 있어서는 Java보단 Javascript가 더 깔끔합니다!

수고많으셨습니다!

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.

문제 풀이가 깔끔하네요 👍

@@ -0,0 +1,14 @@
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
}
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.

항상 함수 분리를 깔끔하게 잘 하시는 군용!

@sik9252 sik9252 merged commit 9f88bd2 into main Apr 9, 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