Skip to content

Climbing Stairs#26

Merged
asuan99 merged 1 commit intomainfrom
legitgoons/climbing-stairs
Dec 26, 2024
Merged

Climbing Stairs#26
asuan99 merged 1 commit intomainfrom
legitgoons/climbing-stairs

Conversation

@Legitgoons
Copy link
Collaborator

문제

Type Info
Time Complexity 0ms
Space Complexity 50.92mb
Algorithm DP
Data Structure Array

Constraints

  • 1 <= n <= 45

Edge Case

  • 없음

풀이

  • 1칸 Or 2칸
    • n = 1 return 1
    • n = 2 return 2
    • n = 3 return 3
    • n = 4 return 5 [1, 1, 1, 1] [2, 1, 1] [1, 2, 1] [1, 1, 2] [2, 2]
    • n = 5 return 8 [1, 1, 1, 1, 1] [2, 1, 1, 1] [1, 2, 1, 1][1, 1, 2, 1][1, 1, 1, 2][2, 2, 1][2, 1, 2][1, 2, 2]
  • 1, 2, 3, 5, 8 -> n = (n-2)번째 + (n-1)번째

어려웠던 점

  • 처음에는 새로운 함수 호출하는 방식으로 구현했으나, 시간복잡도가 O(2^n)으로 최악
    • 반복문 돌리는 방법으로 변경

알게된 점

  • 점화식 방식으로 함수 중복호출하는 건 시간복잡도가 매우 높다.

@asuan99 asuan99 merged commit 977f605 into main Dec 26, 2024
1 of 2 checks passed
@BangDori BangDori deleted the legitgoons/climbing-stairs branch December 26, 2024 13:20
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.

2 participants