#3216
Lexicographically Smallest String After a Swap
pupil · 435 · lc easy +25 · 54.5% accepted · 100 likes · top 47%
Description
You are given a digit-only string s. You may perform at most one swap of two adjacent digits that share the same parity (both odd or both even).
Return the lexicographically smallest result achievable.
Code
1
2
3