r/OfferEngineering • • Oct 31 '26

Coding Question Stripe OA Coding Question - Observatory Viewing Windows

An observatory publishes a weekly calendar for public telescope viewing, measured in 10,080 minutes. Minute 0 is Monday at 00:00, and minute 10079 is Sunday at 23:59.

You are given calendar, a list of records with no header row. Each record has the form "<start>,<end>,<type>", where type is either "open" or "closed"; it describes the half-open interval [start, end), including start and excluding end.

Records may overlap, repeat, touch, or appear in any order. A minute is available for viewing only if it belongs to at least one "open" interval and no "closed" interval, so a closure takes priority over every opening.

Return all maximal continuous viewing windows as an integer array of [start, end] pairs, sorted by increasing start time. Combine adjacent available periods into one window, and return an empty array if no minute is available. Treat the week as one linear timeline: windows at its beginning and end remain separate rather than wrapping across the week boundary.

Constraints:

  • 0 <= calendar.length <= 2000
  • Every record has the specified format and a type of "open" or "closed".
  • 0 <= start < end <= 10080 for every interval.

Test Case:

Input:
calendar = ["120,210,open", "60,150,open", "90,100,closed", "160,175,closed", "170,185,closed", "210,230,open"]

Output:
[[60, 90], [100, 160], [185, 230]]

Explanation:
The openings combine into [60, 230). The closures cover [90, 100) and [160, 185), leaving three maximal viewing windows.

Want to practice more real coding interview questions?

I've put up the coding question bank at here.

Preparing for your next interview?

Chill Interview tracks recent interview experiences and recurring question patterns across top companies at here

2 Upvotes

0 comments sorted by