Maximize the Remaining String Solution Codeforces Round #710 Div. 3

You are given a string ss, consisting of lowercase Latin letters. While there is at least one character in the string ss that is repeated at least twice, you perform the following operation: you choose the index ii (1≤i≤|s|1≤i≤|s|) such that the character at position ii occurs at least two times in the string ss, and delete the character at position ii, that is, replace ss with s1s2…si−1si+1si+2…sns1s2…si−1si+1si+2…sn. For example, … Read more