Tap here to switch tabs
Problem
Submissions

Problem: Lexicographically Smallest String After a Swap

med
30 min
Try to solve the Lexicographically Smallest String After a Swap problem.

Statement

Given a string s consisting of digits, you are permitted to swap at most 11 pair of adjacent digits provided that both digits share the same parity (both are even or both are odd).

Return the lexicographically smallest string that can be obtained after applying at most 11 such swap.

Constraints:

  • 2≤2 \leq s.length ≤100\leq 100

  • s consists only of digits.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Lexicographically Smallest String After a Swap

med
30 min
Try to solve the Lexicographically Smallest String After a Swap problem.

Statement

Given a string s consisting of digits, you are permitted to swap at most 11 pair of adjacent digits provided that both digits share the same parity (both are even or both are odd).

Return the lexicographically smallest string that can be obtained after applying at most 11 such swap.

Constraints:

  • 2≤2 \leq s.length ≤100\leq 100

  • s consists only of digits.