Frog Jump
hardTime: O(n²)Space: O(n²)
Signals to notice
frog jumping on stonesnext jump depends on last jumpstate = (position, last jump size)
Brute force first
Try all jump sequences — exponential.
The key insight
Map each stone to set of reachable jump sizes. For each (stone, k): try k-1, k, k+1 to next stones. O(n²).
What must stay true
State = (position, last jump). Same position with different last jumps has different options. Set per stone avoids duplicates.
Easy way to go wrong
Not tracking jump size — options depend on how you arrived, not just where you are.