class Solution():
    def climbStairs(self, n):
        """
        :type n: int
        :rtype: int
        """
        dp = [1 for i in range(n+1)]
        for i in range(2, n+1):
            dp[i] = dp[i-1] + dp[i-2]

        return dp[n]

class Solution1:
    """
    @param n: An integer
    @return: An integer
    """
    def climbStairs(self, n):
        # write your code here
        if n == 0:
            return 0

        if n == 1:
            return 1

        if n == 2:
            return 2

        dp = [0 for i in range(n)]
        dp[0] = 1
        dp[1] = 2
        for i in range(2, n):
            dp[i] = dp[i-1] + dp[i-2]

        return dp[n-1]

class Solution2:
    """Memozation"""
    def climbStairs(self, n, memo = {}):
        if n in memo:
            return memo[n]

        if n < 0:
            return 0
        if n == 0:
            return 1

        memo[n] = self.climbStairs(n-1) + self.climbStairs(n-2)
        return memo[n]


if __name__ == "__main__":
    sln = Solution1()
    nstairs = 20
    res = sln.climbStairs(nstairs)
    print(res)
