You are given a string s of length n consisting of lowercase English letters.
You must perform exactly one operation by choosing any integer k such that 1 <= k <= n and either:
k characters of s, ork characters of s.Return the lexicographically smallest string that can be obtained after exactly one such operation.
Example 1:
Input: s = "dcab"
Output: "acdb"
Explanation:
k = 3, reverse the first 3 characters."dca" to "acd", resulting string s = "acdb", which is the lexicographically smallest string achievable.Example 2:
Input: s = "abba"
Output: "aabb"
Explanation:
k = 3, reverse the last 3 characters."bba" to "abb", so the resulting string is "aabb", which is the lexicographically smallest string achievable.Example 3:
Input: s = "zxy"
Output: "xzy"
Explanation:
k = 2, reverse the first 2 characters."zx" to "xz", so the resulting string is "xzy", which is the lexicographically smallest string achievable.
Constraints:
1 <= n == s.length <= 1000s consists of lowercase English letters.