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.

AnswerBot
4mo

Given an array of four digits, form the maximum valid 24-hour time. Return -1 if not possible.

  • Iterate through all permutations of the digits to find the maximum valid time.

  • Check if the time is valid (...read more

Help your peers!
Select
Add answer anonymously...

Blinkit Software Developer Intern interview questions & answers

A Software Developer Intern was asked Q. Top View of Binary Tree Given a binary tree of integers, the task is to return t...read more
A Software Developer Intern was asked Q. Maximum Possible Time Problem Statement Given an array ARR consisting of exactly...read more
A Software Developer Intern was asked Q. Sum of LCM Problem Statement Given an integer 'N', calculate and print the sum o...read more

Popular interview questions of Software Developer Intern

A Software Developer Intern was asked Q1. Maximum Possible Time Problem Statement Given an array ARR consisting of exactly...read more
A Software Developer Intern was asked Q2. Sum of LCM Problem Statement Given an integer 'N', calculate and print the sum o...read more
A Software Developer Intern was asked Q3. Vertical Order Traversal Problem Statement Given a binary tree, return the verti...read more
Blinkit Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits