Tap here to switch tabs
Problem
Submissions

Problem: Longest Fibonacci Subarray

Try to solve the Longest Fibonacci Subarray problem.

Statement

Given an array of positive integers nums, find the length of the longest Fibonacci subarray.

A subarray of nums is called a Fibonacci subarray if:

  • Its length is at least 22.

  • Every element from the third element onward is equal to the sum of the preceding two elements.

Return the length of the longest Fibonacci subarray in nums.

Note: A subarray is a contiguous non empty sequence of elements within an array.

Constraints:

  • 3≤3 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Fibonacci Subarray

Try to solve the Longest Fibonacci Subarray problem.

Statement

Given an array of positive integers nums, find the length of the longest Fibonacci subarray.

A subarray of nums is called a Fibonacci subarray if:

  • Its length is at least 22.

  • Every element from the third element onward is equal to the sum of the preceding two elements.

Return the length of the longest Fibonacci subarray in nums.

Note: A subarray is a contiguous non empty sequence of elements within an array.

Constraints:

  • 3≤3 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9