Trains the technique from
LeetCode 873Length of Longest Fibonacci SubsequenceThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
The list gauges is strictly increasing. A ladder is a selection of three or more of its readings, kept in the order they appear in the list, where every reading after the first two equals the sum of the two readings before it.
Return the length of the longest ladder, or 0 when the list holds none.
Example 1
Every reading from the third onwards is the sum of the two before it, so the whole list is one ladder.
Example 2
No reading is the sum of two earlier ones, so there is no ladder at all.
Example 3
Take 3, 6, 9, 15 and 24: each rung is the sum of the two before it. A sixth rung would have to be 39, which the list does not hold.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def len_longest_fib_subseq(gauges: list[int]) -> int:public int lenLongestFibSubseq(int[] gauges)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.