Python beat 99% solution.


  • 0
    H

    class Solution(object):
    def climbStairs(self, n):
    """
    :type n: int
    :rtype: int
    """
    a,b,p,q = 1,0,0,1
    while n != 0:
    if n % 2 == 0:
    p, q = pp + qq, qq + 2pq
    n = n / 2
    else:
    a, b = (p+q)a + qb, a
    q + b*p
    n -= 1
    return a


Log in to reply
 

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