Problem Statement | |||||||||||||
Given a sequence of positive integers in nondescending order you can make a string by concatenating the sequence elements together. For example, the sequence [1,1,13,934] could become the string "01113934". Given a String str containing digits return how many distinct nondescending sequences could have produced str. Two sequences are distinct if they differ in some position, or have different lengths. When put into str, the sequence element could have been padded with leading zeros. For example, [1,2] could become "12", "00010002", "010002" as well as numerous other possible strings. You should assume the integers in the original sequence were between 1 and 1000000 inclusive. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | str must contain between 1 and 50 characters inclusive. | ||||||||||||
- | Each character of str must be a digit ('0' - '9'). | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
| |||||||||||||
5) | |||||||||||||
|