Solved LeetCode program · 644 of 1,000
#0873 · Length of Longest Fibonacci Subsequence
Original English source
Keep a shared numbers holding 1, 2, 3, 4, 5, 6, 7, and 8. Keep a shared located of -1. Keep a shared best of 0. Keep a shared tally of 2.
To locate from goal (a whole number) with spot (a whole number). If spot is more than the last position of numbers, return. If item spot of numbers is goal, set located to spot, return. Locate from goal with spot plus 1.
To collect from first (a whole number) with second (a whole number). If tally is more than best, set best to tally. The wanted is item first of numbers plus item second of numbers. Set located to -1. Locate from wanted with second plus 1. If located is at least 0, set tally to tally plus 1, Collect from second with located.
The last is the last position of numbers.
For every first from 0 to last.
For every second from first plus 1 to last.
Set tally to 2. Collect from first with second.
If best is less than 3, set best to 0. Show best.
Expected stdout
5