Maximum Possible Time Problem Statement
Given an array ARR
consisting of exactly four integer digits, your task is to form the maximum possible valid time in a 24-hour format using those digits.
Explanation:
The 24-hour time format ranges from 00:00
to 23:59
. If it's not possible to generate a valid time from the given digits, return -1
.
Input:
T
ARR[0] ARR[1] ARR[2] ARR[3]
...(for each test case T)
Output:
Maximum time in HH:MM format for each test case or -1 if no valid time can be generated.
Example:
Input:
1
1 2 3 4
Output:
23:41
Constraints:
1 <= T <= 10
0 <= ARR[i] <= 9
- Time Limit: 1 second
Note:
You do not need to print anything; the code should return the valid string representation of the time.
Be the first one to answer
Add answer anonymously...
Top Blinkit Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app