Tap here to switch tabs
Problem
Submissions

Problem: Length of Longest Fibonacci Subsequence

med
30 min
Try to solve the Length of Longest Fibonacci Subsequence problem.

Statement

Given an array of strictly increasing positive integers arr, find the length of the longest Fibonacci like subsequence of arr. If no such subsequence exists, return 00.

A sequence x1,x2,…,xkx_1, x_2, \dots, x_k is considered Fibonacci like if:

  • k≥3k \geq 3

  • xi+xi+1=xi+2x_i + x_{i+1} = x_{i+2} for all 1≤i≤k−21 \leq i \leq k - 2

A subsequence is obtained by deleting zero or more elements from arr without altering the relative order of the remaining elements.

Constraints:

  • 3≤3 \leq arr.length ≤1000\leq 1000

  • 1≤1 \leq arr[i] << arr[i + 1] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Length of Longest Fibonacci Subsequence

med
30 min
Try to solve the Length of Longest Fibonacci Subsequence problem.

Statement

Given an array of strictly increasing positive integers arr, find the length of the longest Fibonacci like subsequence of arr. If no such subsequence exists, return 00.

A sequence x1,x2,…,xkx_1, x_2, \dots, x_k is considered Fibonacci like if:

  • k≥3k \geq 3

  • xi+xi+1=xi+2x_i + x_{i+1} = x_{i+2} for all 1≤i≤k−21 \leq i \leq k - 2

A subsequence is obtained by deleting zero or more elements from arr without altering the relative order of the remaining elements.

Constraints:

  • 3≤3 \leq arr.length ≤1000\leq 1000

  • 1≤1 \leq arr[i] << arr[i + 1] ≤109\leq 10^9