Solving Split Array into Fibonacci Sequence in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

  • F.length >= 3;

Also, note that when splitting the string into pieces, each piece must not have extra leading zeroes, except if the piece is the number 0 itself.

Example 1:

Input: "123456579"
Output: [123,456,579]

Example 2:

Input: "11235813"
Output: [1,1,2,3,5,8,13]

Example 3:

Input: "112358130"
Output: []
Explanation: The task is impossible.

Example 4:

Input: "0123"
Output: []
Explanation: Leading zeroes are not allowed, so "01", "2", "3" is not valid.

Example 5:

Input: "1101111"
Output: [110, 1, 111]
Explanation: The output [11, 0, 11, 11] would also be accepted.

Note:

See the full details of the problem Split Array into Fibonacci Sequence at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go