Given a sequence of base-10 digits, output the longest list of integers that contains all the digits exactly once, in the order in which they appeared in the input, without repeating any integers.
Input: 12345 Output: [1, 2, 3, 4, 5] Input: 12123 Output: [1, 2, 12, 3] Input: 10010 Output: [100, 1, 0] Input: 35353 Output: [35, 3, 53] or [3, 5, 353] Input: 988382 Output: [9, 88, 3, 8, 2]
- Use any convenient formats for input and output
- You must support input sequences of up to 10,000 digits long.
- You must support integers of 18 decimal digits or more (This will fit in 64-bit integers, though you may want work with strings anyway)
- You may assume that the input given can be made into a sequences where the 18-digit number requirement is possible.
- If there is more than one possible longest sequence, you may output any one of them.
- Numbers in the output sequence may not be zero-padded.
- Zero is a valid element, but it can, of course, only be used once in the output.
- There is no time or complexity requirement.
- Shortest code wins.
988382 -> [ 9, 88, 3, 8, 2 ]. \$\endgroup\$