Next lexicographical string
Write code to print the lexicographical next string for a given
in dictionary, next word after this word but having similar letters)
the number of characters at the end of string that are sorted
e.g. in "abcgda" the length of such sub-string is 3 (
look at the char before this sub-string (here it is 'c' ).
character must be replaced with the smallest character in
decreasing sub-sequence which is bigger than this char (here it's
sort the decreasing sub-string to be increasing
the next lexicographical string of "abcgda" is "abdacg"
('d' is replaced
'c' and then "gca" is sorted to be "acg")
If a string is sorted decreasingly like "dcba" it's next
exist so it's next string doesn't exist