Frog Jump

Hard · Dynamic Programming · about 30 minutes

Asked at Amazon, Google, Snap, ByteDance, Oracle, Discord, Riot Games.

A frog crosses a river on stones at sorted positions stones (the first is 0). Its first jump must be 1 unit. If its last jump was k units, the next must be k - 1, k or k + 1 units, landing on a stone. Return true if it can reach the last stone.

Related guides