Code RoomFibonacci-like sequence split
MediumPrep Room Coding #932

Fibonacci-like sequence split

CodingAlgorithms & data structuresMid–Senior~30 min

Given a string num of digits (length 1..30), split it into a sequence of non-negative integers that forms a Fibonacci-like sequence: every number (from the third on) equals the sum of the previous two. The sequence must have at least 3 numbers, no number may have a leading zero (except the single digit '0'), and every value must fit in a signed 32-bit integer (< 2^31). Return any one valid split as a list of integers, or an empty list if none exists.

Implement
split_into_fibonacci(num: str) → list[int]
Examples
in["1101111"]out[11,0,11,11]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 30 min
InputExpectedGot
["1101111"][11,0,11,11]not run yetsample