Code Room
CodingEasycod-g1493
Subject Dynamic programming 1dLevel Entry–Mid~10 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Your road-trip app records the elevation (in meters, an integer) at each waypoint in order. Riders want to know the biggest single descent available: the largest value of an earlier waypoint's elevation minus a later waypoint's elevation. The two waypoints need not be adjacent, but the higher one must come first. Return that maximum drop, or 0 if the route never descends (or has fewer than two waypoints). For example, [100, 80, 120, 60] gives 60 (120 down to 60).

Implement
biggest_descent(elevations: list[int]) → int
Examples
in[[100,80,120,60]]out60
in[[1,2,3]]out0
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.