递归

    def jumpFloor(self, number):
        # write code here

        res = {} # 暂存
        print(res)
        if number == 1:
            return 1
        elif number == 2:
            return 2
        return self.jumpFloor(number - 1) + self.jumpFloor(number - 2)

动态规划

    def jumpFloor(self, number):
        """
        动态规划优化:状态压缩
        :param number:
        :return:
        """
        if number == 1:
            return 1
        elif number == 2:
            return 2
        l1 = 1
        l2 = 2
        for i in range(3,number + 1 ):
            temp = l1 + l2
            l1 = l2
            l2 = temp
        return l2