<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 {
public:
    vector<int> splitIntoFibonacci(string num) {
        vector<int> result;
        vector<int> temp;
        int n = num.size();
        
        // Try every possible split for the first and second number
        for (int i = 1; i < n && i <= 10; ++i) { // First number length
            if (num[0] == '0' && i > 1) break; // Leading zero check
            long long first = stoll(num.substr(0, i));
            if (first > INT_MAX) break; // Out of bounds check
            
            for (int j = i + 1; j < n && j <= i + 10; ++j) { // Second number length
                if (num[i] == '0' && j > i + 1) break; // Leading zero check
                long long second = stoll(num.substr(i, j - i));
                if (second > INT_MAX) break; // Out of bounds check
                
                temp.clear();
                temp.push_back(first);
                temp.push_back(second);
                if (backtrack(num, j, temp)) {
                    return temp;
                }
            }
        }
        
        return result;
    }
    
private:
    bool backtrack(const string& num, int start, vector<int>& temp) {
        if (start == num.size()) {
            return temp.size() >= 3;
        }
        
        // Calculate the expected sum for the next number
        long long sum = static_cast<long long>(temp[temp.size() - 1]) + temp[temp.size() - 2];
        string sumStr = to_string(sum);
        
        // Check if the next segment of the string matches the expected sum
        if (num.substr(start, sumStr.size()) != sumStr) {
            return false;
        }
        
        // Convert the segment to a number and ensure it's within valid range
        long long nextNumber = stoll(sumStr);
        if (nextNumber > INT_MAX) {
            return false;
        }
        
        temp.push_back(nextNumber);
        return backtrack(num, start + sumStr.size(), temp);
    }
};
11100