Skip to content

[WEEK04-2] 최준호#15

Merged
raejun92 merged 2 commits intomainfrom
raejun
Mar 8, 2026
Merged

[WEEK04-2] 최준호#15
raejun92 merged 2 commits intomainfrom
raejun

Conversation

@raejun92
Copy link
Collaborator

@raejun92 raejun92 commented Mar 4, 2026

이렇게 풀었어요

1. Climbing Stairs

  • 문제를 풀었어요.
  • 풀이 시간 : 풀지 못함

1) 복잡도 계산

시간 복잡도: O(2^n)


2) 접근 아이디어

재귀 알고리즘을 이용하여 풀이했다.


3) 회고

재귀 알고리즘을 이용해서 문제를 풀려고 했다.
재귀 알고리즘은 풀이가 간단하지만 시간 복잡도가 O(2^n)으로 매우 비효율적이다.
다른 사람들의 풀이를 보니 DP로 푼 것이 시간 복잡도 측면에서 더 효율적으로 나왔다.



2. Longest Palindrome

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

1) 복잡도 계산

시간 복잡도: O(n)


2) 접근 아이디어

HashMap을 이용해서 문제를 풀었다.
문자열을 순회하면서 각 문자의 개수를 HashMap에 저장했다.
HashMap을 순회하면서 각 문자의 개수가 짝수인 경우에는 그대로 더해주고, 홀수인 경우에는 1을 더해주고 나머지는 더해주는 방식으로 풀이했다.


3) 회고

문제 이해를 잘못해서 문자를 포함시키면 무조건 다 써야 하는 걸로 이해했다.
짝수는 모두 사용하고 길이가 가장 긴 홀수만 더했더니 실패하였다.
이후 문제를 다시 보니 홀수개 문자도 짝수개 만큼 더하면 된다는 사실을 이해하고 풀이를 완성할 수 있었다.



doitchuu
doitchuu previously approved these changes Mar 5, 2026
Copy link
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.

고생하셨습니다 👍 저희 스터디 초반에 푼거 보면 저희도 많이 성장한 거 같아요!!!
항상 열심히시군요 💯 파이팅입니닫

재귀 알고리즘을 이용해서 문제를 풀려고 했다.
재귀 알고리즘은 풀이가 간단하지만 시간 복잡도가 O(2^n)으로 매우 비효율적이다.
다른 사람들의 풀이를 보니 DP로 푼 것이 시간 복잡도 측면에서 더 효율적으로 나왔다.
*/
Copy link
Member

Choose a reason for hiding this comment

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

이런 식으로 재귀 알고리즘을 유지하되 메모이제이션을 활용하는 방법도 있는 것 같아요.
이 풀이도 신박해서 가져와봤습니다..!

Suggested change
*/
var climbStairs = function(n) {
const memo = new Array(n + 1).fill(0);
function dfs(k) {
if (k <= 2) return k;
if (memo[k]) return memo[k];
memo[k] = dfs(k - 1) + dfs(k - 2);
return memo[k];
}
return dfs(n);
};

let isOdd = true;

for (const [_, v] of map) {
console.log(_, v);
Copy link
Member

Choose a reason for hiding this comment

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

요런 console 도 지워주면 더 좋을 것 같습니다 👍

let sum = 0;
let isOdd = true;

for (const [_, v] of map) {
Copy link
Member

Choose a reason for hiding this comment

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

값만 필요하니, 이렇게 풀어줘도 깔끔할 것 같아요!

Suggested change
for (const [_, v] of map) {
for (const v of map.values()) {
// v는 count
}

Copy link
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.

하고싶은 얘기들 이미 슬기님이 다 해주신듯하여..!! 요새 다들 문제도 빨리 풀고, 코멘트도 엄청 빨리빨리 남기시고 열정이 대단한거같아 좋네요 ㅎㅎ

@raejun92 raejun92 merged commit 213c0d4 into main Mar 8, 2026
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.

3 participants