Odd To Even
You can use swap operation over any two indices i,e you can choose two indices 'i' and 'j' and swap the digits present at S[i] and S[j]. But this operation can be used only once. Your final even number should be the largest out of all other possible even numbers.
If it isn’t possible to make an even number print -1
The first line of the input contains ‘T’ denoting the number of test cases. The first and the only line of each test case contains a string ‘S’ the odd number.
If it is possible to make even number print largest out of all. Else print -1 Print the result of each test case in a new line.
1 <= T <= 5 0 <= |S| <= 10^5 Time Limit : 1 sec
Ninja and Numbers
Longest Palindromic Substring