Golang 0ms DP


  • 0
    R
    func climbStairs(n int) int {
        if n == 0 {return 0}
        if n == 1 { return 1}
        var a uint32 =1
        var b uint32 =1
        var ret uint32 = 0
        
        for i:=2; i <=n; i++ {
            ret = a + b
            b = a
            a = ret
        }
        return int(ret)
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.