Practice Length of Longest Fibonacci Subsequence
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
From strictly increasing positive array arr, find the longest subsequence of at least three values in which each value after the first two equals the sum of the two values immediately before it. Preserve array order. Return its length, or 0 if no such subsequence exists.
Source: Length of Longest Fibonacci Subsequence on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
arr = [1,2,3,4,5,6,7,8]
Output
5
# Example 2
Input
arr = [1,3,7,11,12,14,18]
Output
3
Constraints
3 <= arr.length <= 1000
1 <= arr[i] < arr[i + 1] <= 10^9
Related LeetCode Problems
Practice more problems similar to Length of Longest Fibonacci Subsequence.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.