Make the String lexicographically larger
Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article
Given a string str of length n. The task is to find a lexicographic largest string where you are allowed to shift one character from str to any other index only one time.Examples:Input: n = 3, str = “bac”Output: “cba”Explanation: We can perform the given operation exactly one time on the string str and make many strings. Among them “cba” is lexicographically greater.Input: n = 6, str = “bacatf”Output: tbacaf Approach: This can be…