Given an array/list ‘ARR’ having 4 integer digits only. The task is to return the maximum 24 hour time that can be formed using the digits from the array.
Note:
The minimum time in 24-hour format is 00:00, and the maximum is 23:59. If a valid time cannot be formed then return -1.
Example:
We have an array ARR = {1, 2, 3, 4} so the maximum time that will be formed will be 23:41.
Input format:
The very first line of input contains an integer ‘T’ denoting the number of test cases.
The first line of every test case contains four integers.
Output format:
For each test case, return the maximum time if found otherwise return -1.
Output for each test case is printed on a separate line.
Note:
You do not need to print anything, it has already been taken care of. Just return the valid string.
Constraints:
1 <= T <= 10
0 <= ARR[i] <= 9
Time Limit: 1 sec