Problem Statement | |||||||||||||
You will be given a String[] cars containing a list of strings that will participate in the Train.
The Train is a string that will be built using the given strings. The building process works as follows:
Once you have built the Train, remove all but the last occurrence of each character in the Train. For example, if the Train was (quotes for clarity) "abbbcabdb" you would be left with "cadb". You will return a string of the form "n x" where, n is the length of the Train before removing all but the last occurrence of each character, and x is the string after the removal. n and x are separated by exactly one space, the return should not have any leading or trailing whitespace, and n should have no leading zeros. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | cars will contain between 2 and 50 elements inclusive | ||||||||||||
- | Each element of cars will contain between 1 and 50 uppercase letters inclusive | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|