Problem Statement | |||||||||||||
| You are given a String[] words, each element of which is a single word. Return a String[] where the i-th element is the abbrevation for the i-th word. The abbreviation for a word is its shortest non-empty prefix that is not a prefix of any other given word. The constraints will guarantee that it is possible to find an abbreviation for all the given words. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
| - | A string s1 is called a prefix of string s2 if and only if s1 can be obtained by removing zero or more characters from the end of s2. | ||||||||||||
Constraints | |||||||||||||
| - | words will contain between 1 and 50 elements, inclusive. | ||||||||||||
| - | Each element of words will contain between 1 and 50 characters, inclusive. | ||||||||||||
| - | Each element of words will only contain lowercase letters ('a'-'z'). | ||||||||||||
| - | No element of words will be a prefix of another element of words. | ||||||||||||
Examples | |||||||||||||
| 0) | |||||||||||||
| |||||||||||||
| 1) | |||||||||||||
| |||||||||||||
| 2) | |||||||||||||
| |||||||||||||
| 3) | |||||||||||||
| |||||||||||||
| 4) | |||||||||||||
| |||||||||||||