We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Bigger is Greater
Bigger is Greater
Sort by
recency
|
991 Discussions
|
Please Login in order to post a comment
Going from right to left, stop as soon as the predecessor character is greater than the current character. Then find the rightmost such such character and swap. Finally, sort the characters to the right of the current character. The effect of this procedure is to find the lowest possible lexicographic position which, when incremented by swapping, will be greater than the original string, and then to minimze all the lower positions. The resulting string is guaranteed to be lexicographically greater than the original, and any swap will be either greater than this string or smaller than the original string.
RUST:
It's just The Narayana Panditha's algorithm - indian mathematician from XIV century
If you're looking for a bigger, better outdoor experience, a tilting outdoor umbrella is a must! It offers shade where you need it most and adjusts easily to keep you cool all day long. Perfect for those sunny afternoons or casual outdoor gatherings. You'll definitely enjoy the comfort and convenience!
Perl solution: