Problem Statement
Create a class MakeUnique that contains a method eliminated that is given a
If there is no way to do this, return a
If there are several ways to do this, choose the one with the shortest length
between the first and last remaining letters. If there are still several ways,
return the
Definition
- Class:
- MakeUnique
- Method:
- eliminated
- Parameters:
- String
- Returns:
- String
- Method signature:
- String eliminated(String original)
- (be sure your method is public)
Constraints
- original will contain between 1 and 50 characters inclusive
- each character in original will be an uppercase letter 'A'-'Z'
Examples
"ABBBXCXABCX"
Returns: ".......ABCX"
The 4 letters ABCX must remain, and in that order. "AB...CX...." would also leave these letters in the appropriate order, but the length between the first and last remaining letters would be longer than in the given answer.
"ABBBXCXABCB"
Returns: "A..B.CX...."
"AB...CX...." and "A.B..CX...." are also possible and have the same length between first and last remaining letters, but they come later lexicographically than the given answer.
"ABBBXCABCB"
Returns: ""
There is no way to eliminate letters and end up with C before X.
"AABACBXABX"
Returns: ".AB.C.X..."
"CABDEAFDEGSDABCDEADFGSEFBGS"
Returns: "............ABCDE..FGS....."
"AAAAAA"
Returns: ".....A"
"AABCDEFGGGGGGGGGGGGGGGGGGGGGGGHIJKLMNOPQRSTUVWXYZZ"
Returns: ".ABCDEF......................GHIJKLMNOPQRSTUVWXYZ."
"X"
Returns: "X"
"ABCBCABCBABCCBABBCBBCABCAABCAB"
Returns: ".........................ABC.."
"ABCBCABCBABCCBABBCBBCABAAABBAB"
Returns: ".........ABC.................."
"ABDDCBCABCBABCCBABBCBBCABAAABBAB"
Returns: ""
"ACBCABAAACBBBCCBABBACBBCABAAABBAB"
Returns: "A.BC............................."
"ACBACABAAACBBBCCBABBACBBCABAAABBAB"
Returns: "....................A..BC........."
"GD"
Returns: ""
"ABCDCDDDDDACDCDCDCCCCCDEBCAAACADAEACBDCD"
Returns: "..........A.............B....C.D.E......"
"ABDCDDDDDACDCDCDCCCCCDEBCAAACADAEACBDCD"
Returns: "AB..................CDE................"
"ACBCAEBCBEFEECFAACAEDECFDFAECFDAADDCFEADCBDDBDDDEE"
Returns: "....A...B........C..DE.F.........................."
"DACBCBDDDDCBCDADABDCCCDCCADBACCB"
Returns: ".A.BC.D........................."
"AC"
Returns: "AC"
"DEBEECCABCDEEAAADCBCADAEBB"
Returns: ".......ABCDE.............."
"EEF"
Returns: ".EF"
"C"
Returns: "C"
"GDEEFCHDCGGHCCEHBICBBDEBBBFGBIGEEIHIDIHCHBHBGDCC"
Returns: "................B.C..DE...F...G...HI............"
"CACBBCBCABBBCBACBAB"
Returns: "........A..BC......"
"BBACBCCAABABBA"
Returns: "..A.BC........"
"BABBCACBCBCBAA"
Returns: ".....A.BC....."
"BCCABCACABBABBBAABCAABCCBABCBBBBACCA"
Returns: ".........................ABC........"
"BF"
Returns: "BF"
"DBADADBABDCBCBBCBDCBABDCAADCDCDACCBBBBDBABBABBCCA"
Returns: "....................AB.C..D......................"
"BDBABEBCDCACDECCEDCCBBDBECABEDEDAAACBDBBACAEEDED"
Returns: "...A..B....CDE.................................."
"BABCBADBACBBBDCAADDADBBACACBB"
Returns: ".ABC..D......................"
"ADCABAEAEDECDDCEDABBCEABBBEAAAACCEEECBECBCCECBC"
Returns: "...AB......C.D.E..............................."
"BDEDFDEF"
Returns: "BDE.F..."
"BAACDBBCBABDCCBBAADCAA"
Returns: ".........AB..C....D..."
"EDEEAEBCEBAECEEEEEADEBCCEACABDBEAAEBDBDCAEABCAE"
Returns: "..................A..B....C..D.E..............."
"AI"
Returns: "AI"
"CGBFEEDCCECCEGFFCFDABDABGCFFEADAEBDDCAAADDCDFGGF"
Returns: "......................AB.C....D.E...........FG.."
"BEEABDCCDCABAEAABCDCCBABCEAEAABEBABBEDBBC"
Returns: "...............ABCD......E..............."
"DDCCADAABACCCDCAABCCACDCCDCCDD"
Returns: "................AB...CD......."
"CACBCCC"
Returns: ".A.BC.."
"ADBBABDCDAB"
Returns: "....AB.CD.."
"G"
Returns: "G"
"ABCCBCBBBBBBBABCBAAABBBAABABBCBCBBBBCABCCCC"
Returns: ".....................................ABC..."
"EEAEADECCEADBEEFEFCDFFDEFFFAFADEACDFCFBBEFBAD"
Returns: "..........A.B.....C...DEF...................."
"BBCEBBCC"
Returns: ".BCE...."
"BBBCBCBDABAABBBABCAACDCCCDDCCADDACAC"
Returns: "...............AB...CD.............."