Parse Google Maps Opening Hours Text and Answer Is-Open Queries

Last updated: November 29, 2026

Quick Overview

Given a business's opening hours as text such as "Mon-Fri 9am-5pm; Sat 10am-2pm, 4pm-11pm; Sun 6pm-2am", parse it into merged weekly intervals and answer whether the business is open at a given day and time, handling ranges that pass midnight and day ranges that wrap around the week.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given a business's opening hours as text such as "Mon-Fri 9am-5pm; Sat 10am-2pm, 4pm-11pm; Sun 6pm-2am", parse it into merged weekly intervals and answer whether the business is open at a given day and time, handling ranges that pass midnight and day ranges that wrap around the week.

Google Maps shows "Open now" for millions of places whose hours come from merchant-entered text, so this onsite question mixes parsing with interval logic. The interviewer looks for a normalized representation (minutes since Monday 00:00), correct 12am and 12pm handling, and overnight ranges spilling into the next day.

What the Interviewer Expects
  • Chooses a single timeline such as minutes since Monday midnight
  • Parses times with am and pm correctly, including 12am and 12pm
  • Expands day ranges, including wrap-around like Fri-Mon
  • Handles closing times after midnight by spilling into the next day and the week boundary
  • Merges overlapping intervals before answering queries
Key Topics to Cover
String Parsing
Interval Merging
Time Arithmetic
Normalization
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
  • Answer when the place next opens or closes from a given moment.
  • Add holiday overrides and timezone handling for a place near a time-zone border.
  • Queries are very frequent; how would you make each one O(log n)?
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
  • Grammar: clauses separated by ;, each Day or Day-Day, a space, then comma-separated time-time ranges. Times look like 9am, 12:30pm, noon, midnight.
  • A range whose end is not after i...
High-Level Design

Map everything onto one weekly timeline of 7 * 1440 minutes starting Monday 00:00. Each clause expands into one interval per day, offset by day * 1440. Overnight ranges just get +1440 on the end...


Submit Your Answer
Markdown supported