NIHILENT Hiring | On Campus OA (2024) | Largest Number After Digit Swaps by Parity
Question · Posted Jun 2026
Problem Statement You are given a positive integer num. The digits of the number are indexed from 0 to n-1 (left to right). You are allowed to perform any number of swap operations under the following rule: You may swap two digits only if their indices have the same parity. In other words: A digit at an even index can only be swapped with another digit at an even index. A digit at an odd index can only be swapped ...
The full answer & interview discussion are available to premium members.
Log in Create a free account