NewThe Learning module is now liveSee what's new

(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.

Test Cases
Input
Output
Expected