Generate Available Time Slots
Reported by candidates from Stripe's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Stripe asked this in April 2026: generate all valid 30-minute time slots within a date range, respecting weekly working hours. You're not building a calendar UI. You're iterating a date range, checking weekday rules, and filtering slots that fit entirely inside both the working window and the requested span. Candidates often miss the "fully contained" rule on boundaries. StealthCoder reads the constraint once and flags it in real time so you don't lose points to off-by-one logic.
The problem
You are given a datetime range [startDate, endDate] and a weekly recurring working-hours configuration. Generate every available 30-minute slot that is fully contained in the range and also lies inside one of the working-hour windows for the corresponding weekday. Each slot is represented as a string "start,end", where the start and end timestamps are separated by a comma. The first and last days must be validated using the exact time boundaries: a slot is valid only when slotStart >= startDate and slotEnd. Function Description Complete the function generateAvailableTimeSlots in the editor below. generateAvailableTimeSlots has the following parameters: Returns The 09:00-09:30 slot starts before the allowed range, and the 10:30-11:00 slot ends after the allowed range. The two middle 30-minute slots are fully contained. Only the two full 30-minute slots inside both the Tuesday working window and the requested datetime range are returned.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is simulation with boundary validation. Iterate from startDate to endDate. For each day, check its weekday, pull the working hours, then generate 30-minute slots. Keep only slots where slotStart >= startDate and slotEnd <= endDate, AND slotStart and slotEnd both fall within that day's working window. The trick is the "fully contained" rule: a 10:30-11:00 slot that ends after endDate is rejected, not accepted. Most candidates code the iteration correctly but slip on the second boundary check. Format each slot as "start_timestamp,end_timestamp" (exact format matters). Walk through one day by hand before coding loops.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Generate Available Time Slots cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Stripe's OA.
Stripe reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Generate Available Time Slots FAQ
What does 'fully contained' mean here?+
Both the slot start and slot end must satisfy: start >= startDate and end <= endDate. AND both must be inside the working hours for that weekday. If a slot starts at 10:30 but endDate is 11:00, that slot (10:30-11:00) is rejected because its end equals endDate, not strictly before. Read the problem example carefully.
How do I handle the first and last day?+
First day: only generate slots where slotStart >= startDate. Last day: only generate slots where slotEnd <= endDate. Both must also respect the weekday working hours. This is where most bugs live. Test with a range that starts mid-morning and ends mid-afternoon.
What if a day has no working hours?+
Skip it. If Tuesday has no entry in the working-hours config, or the window is empty, no slots are generated for any Tuesday in the range. Your code should handle missing weekdays gracefully without crashing.
Is the timestamp format specific?+
Yes. The problem shows "start,end" with no spaces. Use the exact datetime format provided in the input (usually ISO 8601 or a timestamp object). Check the expected output format in the examples and match it exactly.
Can I assume the range is always valid and working hours don't overlap?+
Usually yes for Stripe-style problems, but don't assume. Code defensively: validate that startDate < endDate, that working-hour windows don't collide, and that your slot generator doesn't create duplicates or gaps. One test case will have edge data.