Conversation
sik9252
approved these changes
Mar 5, 2026
| * @return {number} | ||
| */ | ||
| var climbStairs = function(n) { | ||
| const dp = [1, 2]; |
Collaborator
There was a problem hiding this comment.
오옷 이렇게 바로 집어넣을수도 있는데 전 생각 못하고 Array 생성하고 하나씩 넣었네요 알아갑니당!!
Collaborator
There was a problem hiding this comment.
Map으로 문자 빈도수를 세고, 짝수는 모두 사용 / 홀수는 하나 제외하고 사용한 뒤 마지막에 center 여부만 한 번 처리한 점이 좋은 것 같습니다 ㅎㅎ 다만 for (const [key, value] of map)에서 key를 사용하지 않으니 map.values()로 순회하면 조금 더 깔끔할 것 같아요!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
이렇게 풀었어요
1. Climbing Stairs
1) 복잡도 계산
→ 한 번의 반복문으로 dp 배열 채움
→ dp 배열 사용
2) 접근 아이디어
(n-1번째에서 1칸 올라오기) + (n-2번째에서 2칸 올라오기)
3) 회고
이 문제는 대표적인 DP(피보나치 유형) 문제라 DP로 풀었다..
이해보다 외운 느낌 ㅠ
2. Longest Palindrome
1) 복잡도 계산
→ 문자열 한 번 순회 + map 순회
→ 서로 다른 문자 개수만큼 Map 사용
2) 접근 아이디어
팰린드롬의 구조는 다음과 같다:
3) 회고
처음에는 홀수 처리 로직이 헷갈렸는데
짝수 부분만 쓰고, 홀수는 하나만 중앙에 가능하다는
Palidrome 구조를 이해하니 명확해졌다.
for (const [key, value] of map)대신for (const value of map.values())를 쓰면 더 간결했을 것 같다.다른 사람 풀이에서는 다음처럼
Math.floor(count / 2) * 2를 활용해 짝수 부분만 계산했다.