Expand a Cron Schedule Expression Into Concrete Firing Values

Last updated: November 29, 2026

Quick Overview

Given a five-field cron expression such as "*/15 9-17 * 1,6 1-5", return, for each field (minute, hour, day of month, month, weekday), the sorted list of values on which the job fires, supporting wildcards, ranges, lists, and steps, and rejecting out-of-range input.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given a five-field cron expression such as "*/15 9-17 * 1,6 1-5", return, for each field (minute, hour, day of month, month, weekday), the sorted list of values on which the job fires, supporting wildcards, ranges, lists, and steps, and rejecting out-of-range input.

Google Cloud Scheduler and internal batch systems accept cron syntax, so this is a realistic screen question about turning a compact grammar into data. The interviewer looks for a clean per-field parser, correct step semantics, and validation against each field's bounds.

What the Interviewer Expects
  • Parses each field independently with shared logic and per-field bounds
  • Handles star, single values, ranges, lists, and steps on any of them
  • Defines what a step on a single value means
  • Validates ranges and rejects zero or negative steps
  • Deduplicates and sorts overlapping list items
Key Topics to Cover
Grammar Parsing
Ranges and Steps
Validation
Scheduling
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Compute the next firing time after a given timestamp without enumerating every minute.
  • Cron treats day-of-month and weekday with OR when both are restricted; how would you implement that?
  • Add month and weekday names such as JAN and MON-FRI.
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: five whitespace-separated fields; bounds minute 0..59, hour 0..23, day 1..31, month 1..12, weekday 0..6.
  • Each field is a comma list of items; each item is *, N, or A-B, optionally fol...
High-Level Design

The grammar is regular and small, so no tokenizer is needed: split fields on whitespace, items on commas, and each item on / into a base and an optional step. Turn the base into a [start, end] int...


Submit Your Answer
Markdown supported