BBlinkit·DSASDE-1DSA Phone Screen
Solve the Frog Jumping minimum jumps problem
Given n stones numbered 1..n, each stone may or may not have a frog. A frog can jump over other frogs to any vacant stone ahead. Find the minimum total jumps for all frogs to reach stone n.
The key insight: because frogs can leap over each other, the optimal strategy is for every frog to jump directly to the last stone without blocking others. The minimum number of jumps equals the index of the leftmost occupied stone (1-based) — that frog has the farthest to travel and sets the lower bound. All others can piggyback in fewer moves.
- Time: O(n) to scan for the leftmost frog, or O(1) with direct indexing
- Watch out for edge cases: no frogs present, or a frog already on stone n
added …