Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Nov 23, 2023
1 parent deb320e commit b5d220a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions leetcode/70.ClimbingStairs/climbingStairs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"fmt"
)

func climbStairs(n int) int {
// Fibonaci
if n == 1 || n == 2 {
return n
}

a, b := 0, 1

for i := 0; i < n; i++ {
a, b = b, a+b
}

return b
}

func main() {
n := 3
fmt.Println(climbStairs(n))
}

0 comments on commit b5d220a

Please sign in to comment.