Skip to content

Practice Largest Time for Given Digits

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#949
LeetCode Problem

Largest Time for Given Digits

Problem Statement

Given an array arr of 4 digits, find the latest 24-hour time that can be made using each digit exactly once. 24-hour times are formatted as "HH:MM", where HH is between 00 and 23, and MM is between 00 and 59. The earliest 24-hour time is 00:00, and the latest is 23:59. Return the latest 24-hour time in "HH:MM" format. If no valid time can be made, return an empty string.

Source: Largest Time for Given Digits on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
arr = [1,2,3,4]
Output
"23:41"

# Example 2

Input
arr = [5,5,5,5]
Output
""

Constraints

arr.length == 4
0 <= arr[i] <= 9

Related LeetCode Problems

Practice more problems similar to Largest Time for Given Digits.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.