HUAWEI OD machine test - restore digital sequence (Java & JS & Python)

topic description

For a sequence composed of continuous positive integers, it can be spliced ​​into a string, and then some characters in the string are shuffled. For example, the sequence 8 9 10 11 12, the concatenated string is 89101112, after some characters are disturbed, 90811211 is obtained, and the original positive integer 10 is split into 0 and 1.

Now given a string of scrambled characters obtained according to the above rules, please restore it to a sequence of continuous positive integers, and output the smallest number in the sequence.

enter description

Enter a line, which is a string of shuffled characters and the length of a positive integer sequence. The two are separated by a space. The length of the string does not exceed 200, and the length of the positive integer does not exceed 1000. It is guaranteed that the input can be restored to a unique sequence.

output description

Output a number, which is the smallest number in the sequence.

Example

enter 19801211 5
output 8
illustrate none

topic analysis

The title "String of Disrupted Characters" is composed of "Sequences of Continuous Positive Integers"

Guess you like

Origin blog.csdn.net/qfc_128220/article/details/130912996