Skip to content

Practice Find Number of Ways to Reach the K-th Stair

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#3154
LeetCode Problem

Find Number of Ways to Reach the K-th Stair

Problem Statement

Alice starts on stair 1 with jump = 0; stair 0 is the bottom of an infinite staircase. She may move down one stair unless she is on stair 0 or her previous move was also down. Alternatively, she may move up 2^jump stairs and then increase jump by 1. Given k, count the distinct finite operation sequences ending on stair k. A sequence may visit k, leave it, and return, and using no operations is allowed.

Source: Find Number of Ways to Reach the K-th Stair on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
k = 0
Output
2

# Example 2

Input
k = 1
Output
4

Constraints

0 <= k <= 10^9

Related LeetCode Problems

Practice more problems similar to Find Number of Ways to Reach the K-th Stair.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.