How can I find the lexicographicaly smallest string that doesn't start with a given prefix AND is lexicographicaly bigger than the given prefix? Example:
prefix : cat; next string : cau
prefix : cazz next string; cb
There is no solution if all characters in the input string are equal to the last character in the alphabet (this includes the case of the empty string).
Otherwise, as long as the last character in the input string is the last character in the alphabet, remove it from the string. Then replace the last character of the result with the next character in the alphabet.