Amazon SDE1 ( Jan-Jun 2025) Intern
Anonymous User
559

Coding Question -
Game of Stairs" where the player, Ron, must move from the 1st stair to the M-th stair using a set of rules:
Pressing the Up button moves the character up in powers of 2 (i.e., 2^0, 2^1, 2^2, etc.).
Pressing the Down button brings the character down by one stair, but this button cannot be pressed consecutively.
Stair 1 is stair 1 and ground is stair 0.
The task is to determine the number of ways Ron can move from the 1st stair to the M-th stair.

for input : 1 , output : 4 ...distict way to reach

Can anyone please provide the approach and solution?

Comments (4)