Code Room
CodingHardcod-g524
Subject Dynamic programming 1dLevel Mid–Senior~30 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A frog crosses a river by jumping on stones at the given strictly-increasing positions (the first stone is at 0). Its first jump must be exactly 1 unit. After a jump of k units the next jump must be k-1, k, or k+1 units (and must be positive), landing exactly on a stone. Return whether the frog can reach the last stone. The list has at least one stone.

Implement
frog_jump(stones: list[int]) → bool
Examples
in[[0,1,3,5,6,8,12,17]]outtrue
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.