Description
For this question, the your program is required to process a 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 to multiple segments, and output all segments as one C oncatenated string. The following requirements should also be met,
1. Characters in each segment should is in strictly increasing order. For ordering, ' 9 ' are larger than ' 0 ', ' a ' is larger than ' 9 ', and ' Z ' is larger than ' a ' (basically following ASCII Charac ter order).
2. Characters in the second segment must is the same as or a subset of the first segment; And every following segment must is the same as or a subset of its previous segment.
Your program should output string "<invalid input string>" If the input contains any invalid characters (i.e., out Side the ' 0′-' 9′and ' a '-' Z ' range.
Input
Input consists of multiple cases, one case per line. Each case is one string consisting of ASCII characters.
Output
For each case, print exactly one line with the reordered string based on the criteria above.
Sample input
Aabbccdd
007799aabbccddeeff113355zz
1234.89898
Abcdefabcdefabcdefaaaaaaaaaaaaaabbbbbbbddddddee
Sample output
Abcdabcd
013579abcdefz013579abcdefz
<invalid input string>
Abcdefabcdefabcdefabdeabdeabdabdabdabdabaaaaaaa
Description
Consider a string set that is them consists of {0, 1} only. All strings in the set has the same number of 0s and 1s. Write a program to find and output the k-th string according to the dictionary order. If such a string doesn ' t exist, or the input is not valid, please output "impossible". For example, if we have both ' 0 ' and ' 1 ' s, we'll have a set with 6 different strings, {0011, 0101, 0110, 1001, 1010, 1100}, and the 4th string is 1001.
Input
The first line of the input file contains a single integer t (1≤t≤10000), the number of test cases, followed by the Put data for each test case.
Each test case was 3 integers separated by blank space:n, M (2 <= N + M <= and N, M >= 0), K (1 <= K <= 1 000000000). N stands for the number of ' 0 ' s, M-stands for the number of ' 1 ' s, and K-stands for the k-th of string in the S ET, needs to is printed as output.
Output
For each case, print exactly one line. If The string exists, please print it, otherwise print "impossible".
Sample input
3
2 2 2
2 2 7
4 7 47
Sample output
0101
Impossible
01010111011
Description
Find a pair in an integer array that swapping them would maximally decrease the inversion count of the array. If such a pair exists, return the new inversion count; Otherwise returns the original inversion count.
Definition of Inversion:let (A[0], a[1] ... A[n]) be a sequence of n numbers. If I < J and A[i] > A[j], then the pair (I, j) is called Inversion of A.
Example:
Count (Inversion ({3, 1, 2}) = Count ({3, 1}, {3, 2}) = 2
Inversioncountofswap ({3, 1, 2}) =
{
Inversioncount ({1, 3, 2}) = 1 <–swapping 1 with 3, decreases inversion count by 1
Inversioncount ({2, 1, 3}) = 1 <–swapping 2 with 3, decreases inversion count by 1
Inversioncount ({3, 2, 1}) = 3 <–swapping 1 with 2, increases inversion count by 1
}
Input
Input consists of multiple cases, one case per line. Each case consists of a sequence of integers separated by comma.
Output
For each case, print exactly one line with the new inversion count or the original inversion count if it cannot be reduced .
Sample input
3,1,2
1,2,3,4,5
Sample output
1
0
Description
In a running system, there is many logs produced within a short period of time, we ' d like to know the count of the most F Requent logs.
Logs was produced by a few non-empty format strings, the number of Logs was N (1=n=20000), the maximum length of each log is 256.
Here we consider a log same with another when their edit distance (see note) is = 5.
Also we have a) logs is all the same with each other produced by a certain format string b) format strings has edit dist Ance 5 of each other.
Your program would be dealing with lots of logs, so please try-to-keep the time cost close to O (NL), where n is the number of logs, and L is the average log length.
Note edit distance is the minimum number of operations (insertdeletereplace a character) required to transform one string Into the other and refer to
Http://en.wikipedia.org/wiki/Edit_distance for more details.
Input
Multiple lines of non-empty strings.
Output
The count of the most frequent logs.
Sample input
Logging started for id:1
Module ABC have completed its job
Module XYZ have completed its job
Logging started for Id:10
Module? Have completed its job
Microsoft 2014 Technical Post online PEN test