(This question is a variation of the LeetCode question 2231. Largest Number After Digit Swaps by Parity. If you haven't completed that question yet, it is recommended to solve it first.)
You are given a numeric string num. You may swap two adjacent digits only when they have the same parity, meaning both digits are odd or both are even. You may perform this operation any number of times.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected