<p>You are given a string of digits <code>num</code>, such as <code>&quot;123456579&quot;</code>. We can split it into a Fibonacci-like sequence <code>[123, 456, 579]</code>.</p>

<p>Formally, a <strong>Fibonacci-like</strong> sequence is a list <code>f</code> of non-negative integers such that:</p>

<ul>
	<li><code>0 &lt;= f[i] &lt; 2<sup>31</sup></code>, (that is, each integer fits in a <strong>32-bit</strong> signed integer type),</li>
	<li><code>f.length &gt;= 3</code>, and</li>
	<li><code>f[i] + f[i + 1] == f[i + 2]</code> for all <code>0 &lt;= i &lt; f.length - 2</code>.</li>
</ul>

<p>Note that when splitting the string into pieces, each piece must not have extra leading zeroes, except if the piece is the number <code>0</code> itself.</p>

<p>Return any Fibonacci-like sequence split from <code>num</code>, or return <code>[]</code> if it cannot be done.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> num = &quot;1101111&quot;
<strong>Output:</strong> [11,0,11,11]
<strong>Explanation:</strong> The output [110, 1, 111] would also be accepted.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> num = &quot;112358130&quot;
<strong>Output:</strong> []
<strong>Explanation:</strong> The task is impossible.
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> num = &quot;0123&quot;
<strong>Output:</strong> []
<strong>Explanation:</strong> Leading zeroes are not allowed, so &quot;01&quot;, &quot;2&quot;, &quot;3&quot; is not valid.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= num.length &lt;= 200</code></li>
	<li><code>num</code> contains only digits.</li>
</ul>

class Solution:
    def splitIntoFibonacci(self, num: str) -> List[int]:

        # Helper function to check if a number is a valid 32-bit integer
        def is_valid_number(s: str) -> bool:
            if len(s) > 1 and s[0] == '0':
                # No leading zeros allowed
                return False
            return int(s) <= 2**31 - 1 # Check if it fits in a 32-it signed integer

        # Backtracking function to find the Fibinacci sequence
        def backtrack(index, path):
            if index == len(num) and len(path) >= 3: 
                # If we've processed the intire string
                return path

            current_num = 0
            for i in range(index, len(num)):
                current_num = current_num * 10 + int(num[i]) # Build the current number incrementally

                if not is_valid_number(num[index:i+1]):
                    # Check if valid number
                    break # No need to continue further, invalid number

                # If path has at least two numbers, check the Fibinacci property
                if len(path) >= 2 and current_num > path[-1] + path[-2]:
                    break # Current number is too large, no valid sequence from here

                if len(path) < 2 or current_num == path[-1] + path[-2]:
                    path.append(current_num)  # Add current number to path

                    # Recursively process the rest of the string
                    result = backtrack(i + 1, path)
                    if result:
                        return result # Return early if a valid sequence is found

                    path.pop()
                
            return None

        result = backtrack(0, [])
        return result if result else []

        
16600