You are given a string s consisting only of digits.
A split of s breaks it into one or more consecutive pieces, in order, that together use every character exactly once. Each piece is read as an integer, and a split is valid only when every piece is between 1 and 26 and no piece has a leading zero. A single "0" is never a valid piece on its own.
Return the number of valid splits of s. Return 0 if no valid split exists.
Examples
Example 1
Input: s = "12"
Output: 2
Explanation: The valid splits are "1", "2" and "12".
Example 2
Input: s = "226"
Output: 3
Explanation: The valid splits are "2", "2", "6"; "22", "6"; and "2", "26".
Example 3
Input: s = "06"
Output: 0
Explanation: The only ways to break "06" into pieces are "0", "6" and "06". "0" alone is not a valid piece, and "06" has a leading zero, so no split is valid.
Constraints
1≤s.length≤100
s consists only of digits and may contain leading zeros.
The number of valid splits fits in a 32-bit signed integer.
Loading editor...
Run checks the sample cases; Submit runs every case.
Samples 3
Custom 0
passedwrong answertime limiterrorran, no expected valuenot run