![]() |
VOOZH | about |
Given an odd number in the form of a string, the task is to make the largest even number from the given number, and you are allowed to do only one swap operation.
Examples :
Input: 1235785
Output: 1535782
Explanation: Swap 2 and 5.Input: 536425
Output: 536524
Explanation: Swap 4 and 5 to make the largest even number.
Implementation:
1356524
Time Complexity: O(N)
Auxiliary Space: O(1)