Skip to content

Practice Split Array into Fibonacci Sequence

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#842
LeetCode Problem

Split Array into Fibonacci Sequence

Problem Statement

Split all digits of num into at least three integers forming a Fibonacci-like sequence: every value from the third onward must equal the preceding two values added together. Each value must lie from 0 through 2^31 - 1. A piece may not have leading zeros unless it is exactly 0. Return any valid sequence, or an empty list when none exists.

Source: Split Array into Fibonacci Sequence on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
num = "1101111"
Output
[11,0,11,11]

# Example 2

Input
num = "112358130"
Output
[]

# Example 3

Input
num = "0123"
Output
[]

Constraints

1 <= num.length <= 200
num contains only digits.

Related LeetCode Problems

Practice more problems similar to Split Array into Fibonacci Sequence.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.