You are given a string num consisting only of digits.
Your task is to determine whether the digits can form a valid additive sequence.
An additive sequence is a sequence of numbers where each number is the sum of the previous two, and the sequence contains at least three numbers.
• Numbers in the sequence cannot have leading zeros (e.g., 1, 2, 03 is invalid).
• The sequence must use all digits of the string.
Return true if the number string can form such a sequence, otherwise return false.
Input: num = "23581321"
Output: true
Input: num = "112359"
Output: false
Accepted:
Submission: