FastPrepEnumerate Valid Clock Times
Problems/Enumerate Valid Clock Times

Enumerate Valid Clock Times

Microsoft logoMicrosoft● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Microsoft online assessment. The task is to list clock times from given digits. The report leaves out the clock format and whether a digit can be reused. Here, we use the usual four digits on a 24-hour clock. Our version is about 85% the same as the reported question.

Given exactly four decimal digits in digits, enumerate every valid 24-hour time that can be formed by using each supplied occurrence exactly once.

A valid time has format HH:MM, where 00 <= HH <= 23 and 00 <= MM <= 59. Preserve leading zeroes, remove duplicate times caused by equal digits, and return the times in chronological order.

Function

enumerateValidTimes(digits: int[]) → String[]

Examples

Example 1

digits = [1,2,3,4]return = ["12:34","12:43","13:24","13:42","14:23","14:32","21:34","21:43","23:14","23:41"]

These are exactly the valid chronological arrangements; arrangements such as 31:24 are not valid 24-hour times.

Example 2

digits = [0,0,1,2]return = ["00:12","00:21","01:02","01:20","02:01","02:10","10:02","10:20","12:00","20:01","20:10","21:00"]

The two zero occurrences are both used, and duplicate permutations produce only one copy of each time.

Example 3

digits = [5,5,5,5]return = []

No arrangement has a valid hour.

Constraints

  • digits.length == 4.
  • 0 <= digits[i] <= 9.

More Microsoft Online Assessment questions

  • Minimum Cost to Process Priority TasksOA · Seen Nov 2026
  • Most Visited Sprint MarkerOA · Seen Nov 2026
  • Maximum Escape Game ScoreOA · Seen Nov 2026
  • Count Subarrays with a Perfect-Square ProductOA · Seen Nov 2026
  • Maximum Interactive Team SizeOA · Seen Nov 2026
  • Maximize Pipeline Throughput Under a Scaling BudgetOA · Seen Nov 2026
  • Minimum Cost K-Capable ModelsOA · Seen Nov 2026
  • Find Available Meeting RoomsOA · Seen Oct 2026
  • Maximum Sum of a K-StarOA · Seen Oct 2026
  • Capacity to Ship Packages Within DaysOA · ONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • Sort by Checking PermutationsMercor · PHONE SCREENMercor interview questions
  • Bounded Combination Sum with Signed CandidatesConfluent · ONSITE INTERVIEWConfluent interview questions
  • PermutationsEPAM · PHONE SCREENEPAM interview questions
  • Enumerate Character Paths to a MarkerTesla · ONSITE INTERVIEWTesla interview questions
  • Combination Sum with Single-Use ValuesPinterest · PHONE SCREENPinterest interview questions
  • Subsets IIBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Generate Circular Student ArrangementsAmazon · ONSITE INTERVIEW
  • Partition into Equal-Sum GroupsPalo Alto Networks · ONSITE INTERVIEWPalo Alto Networks interview questions
  • Combination Sum with Unlimited ReuseNVIDIA · PHONE SCREENNVIDIA interview questions
  • Enumerate Compatible Meeting SubsetsExpedia · ONSITE INTERVIEWExpedia interview questions

Microsoft interview experiences

  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
  • Microsoft SWE Intern, Early 2026: 54 Experiences (Part 2 of 6)
  • Microsoft SWE Intern Interviews: 244 Experiences (Part 1 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public String[] enumerateValidTimes(int[] digits) {
        // Write your code here.
    }
}
Checking account…