SHOPPERS STOP DIGITAL On-Campus | Hiring Interview OA (2022)
Question · Posted Jun 2026
Problem: Largest Number After Digit Swaps by Parity Given a positive integer num, you may swap digits only among positions having the same parity: Even index ↔ Even index Odd index ↔ Odd index Return the largest possible integer that can be formed after performing any number of such swaps. Example Input num = 1234 Output 3412 Explanation Digits and positions: Position Digit 0 (Even) 1 1 (Odd) 2 2 (Even) 3 3 (Odd) 4 Even-position digits: [1, 3] → ...
The full answer & interview discussion are available to premium members.
Log in Create a free account