Lexicographic Swap
Given a string s, return the lexicographically smallest string that can be made if you can make at most one swap between two characters in the string.
Constraints
n ≤ 10,000wherenis the length ofs.
https://binarysearch.com/problems/Lexicographic-Swap
Examples
Example 1
Input
- s =
cbca
Output
- answer =
abcc
Explanation
We swap the first "c" and "a"
Leave a comment