Sponsored
Solve with full IDE support and test cases
Use these hints if you're stuck. Try solving on your own first.
Try all possible swaps satisfying the constraints and find the one that results in the lexicographically smallest string.