You are given a non-negative integer k. There exists a staircase with an infinite number of stairs, with the lowest stair numbered 0.
Alice has an integer jump, with an initial value of 0. She starts on stair 1 and wants to reach stair k using any number of operations. If she is on stair i, in one operation she can:
i - 1. This operation cannot be used consecutively or on stair 0.i + 2jump. And then, jump becomes jump + 1.Return the total number of ways Alice can reach stair k.
Note that it is possible that Alice reaches the stair k, and performs some operations to reach the stair k again.
Example 1:
Input: k = 0
Output: 2
Explanation:
The 2 possible ways of reaching stair 0 are:
Example 2:
Input: k = 1
Output: 4
Explanation:
The 4 possible ways of reaching stair 1 are:
Constraints:
0 <= k <= 109Solutions for this problem are being prepared.
Try solving it yourselfClimbing Stairs - Dynamic Programming - Leetcode 70 - Python • NeetCode • 721,911 views views
Watch 9 more video solutions →Practice Find Number of Ways to Reach the K-th Stair with our built-in code editor and test cases.
Practice on FleetCodePractice this problem
Open in Editor