Dsa
Dynamic Programming
Warm-up
Plateau Climbing
You are climbing a series of plateaus, represented as an array of heights, where each height represents a plateau's elevation. Your goal is to find the minimum number of moves needed to reach the top of the highest plateau from the starting point. You can climb either to an adjacent plateau or jump to a plateau that is two steps ahead. If you encounter a plateau that is lower than the previous one you were on, you must backtrack to the last higher plateau.
Input Format:
- The first line contains an integer n (1 ≤ n ≤ 100), the number of plateaus.
- The second line contains n space-separated integers h[i] (1 ≤ h[i] ≤ 10^6), the heights of the plateaus.
Output Format:
- Print a single integer: the minimum number of moves required to reach the highest plateau.
Example:
Input:
5
1 3 2 4 3
Output:
3
Key concepts
dynamic_programmingarraysmemoization
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now