Problem Statement | |||||||||||||
You have a group of non-zero digits, which are not necessarily unique. If you can insert '0' digits wherever you wish, there are an infinite number of integers which have exactly those non-zero digits. For example, given the group of digits {1, 2}, you can create the numbers 12, 21, 102, 120, 201, 210, 1002, 1020, etc. Given a potentially large number n in String format, return how many numbers that use the same exact non-zero digits are less than it. Leading zeros are not allowed. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | n will have between 1 and 50 characters, inclusive. | ||||||||||||
- | n will consist only of digit characters ('0' - '9'). | ||||||||||||
- | n will not start with a '0'. | ||||||||||||
- | There will be at most 2^63 - 1 integers with the same non-zero digits as n that are less than n | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|