Tap here to switch tabs
Problem
Submissions

Problem: Lexicographically Smallest String After a Swap

Lexicographically Smallest String After a Swap asks for the smallest string after at most one adjacent swap between digits with the same parity.

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

Lexicographically Smallest String After a Swap asks for the smallest string after at most one adjacent swap between digits with the same parity.

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.