Case Time Limit:1000ms
For this question, your program is required to process an input string containing only ASCII characters between ‘0’ and ‘9’, or between ‘a’ and ‘z’ (including ‘0’, ‘9’, ‘a’, ‘z’).
Your program should reorder and split all input string characters into multiple segments, and output all segments as one concatenated string. The following requirements should also be met,
1. Characters in each segment should be in strictly increasing order. For ordering, ‘9’ is larger than ‘0’, ‘a’ is larger than ‘9’, and ‘z’ is larger than ‘a’ (basically following ASCII character order).
2. Characters in the second segment must be the same as or a subset of the first segment; and every following segment must be the same as or a subset of its previous segment.
Your program should output string “<invalid input string>” when the input contains any invalid characters (i.e., outside the ‘0’-‘9’ and ‘a’-‘z’ range).
Input consists of multiple cases, one case per line. Each case is one string consisting of ASCII characters.
For each case, print exactly one line with the reordered string based on the criteria above.
- Sample Input
- Sample Output
Default1234abcdabcd013579abcdefz013579abcdefz<invalid input string>abcdefabcdefabcdefabdeabdeabdabdabdabdabaaaaaaa
本文链接地址: Microsoft Online Test for Core Technical Positions 1: String reorder
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。