

In case the string does not contain any even digit, then return -1.
Given string SS = “21”
The output will be 12 since it is the largest even number is formed by swapping 2 and 1.
The first line of input contains an integer T denoting the number of test cases.
The first and the only line of each test case contains a single string ‘S’.
For each test case, return the max possible even number that can be formed. The output of each test case will be printed in a separate line.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= |S| <= 3000
0 <= S[i] <= 9
Where |S| denotes the length of the given string 'S'.
Time Limit: 1 sec
The main idea is to sort the string in descending order, then put the minimum even number at the last position. If no even number is present, then put the minimum number at the last position.
The main idea is to sort the string in descending order, then put the minimum even number at the last position. If no even number is present, then put the minimum number at the last position.
Sorting can be done in linear time using a frequency array for the digits of the number as the number of distinct elements that are needed to be sorted can be at most 10 because it contains digits between 0 - 9 only in the worst case.