A Swift Solution


  • 0
    T
        func climbStairs(n: Int) -> Int {
            var a = 1
            var b = 1
            for i in 0..<n {
                (a, b) = (b, a + b)
            }
        
            return a
        }
    

Log in to reply
 

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