Reported October 2026
Appleprefix sum

Query Weekly Store Opening Hours

Reported by candidates from Apple's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Apple OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this Apple OA, reported in October 2026, is treating a wrapping interval like a normal one. Sunday 22:00 to Monday 02:00 looks like end < start, and a naive start <= t < end check returns false for everything. The problem is Query Weekly Store Opening Hours. Convert each weekly time to minutes since Monday 00:00, then answer up to 100000 queries against up to 100000 intervals. If the wrap logic slips under pressure, StealthCoder is the invisible safety net running during the live OA.

The problem

A store follows weekly opening intervals. Days are numbered 0 through 6 for Monday through Sunday. Each interval is [startDay, startHour, startMinute, endDay, endHour, endMinute] and is half-open: the store is open at its start and closed at its end.
An interval whose end occurs earlier in the week than its start wraps through Sunday into Monday. Intervals may overlap or touch. For every query [day, hour, minute], return whether the store is open at that weekly time.

Function
queryWeeklyStoreHours(openingHours: int[][], queries: int[][]) → boolean[]

Examples
Example 1
openingHours = [[0,8,0,0,10,0],[0,14,0,0,20,0]]
queries = [[0,8,0],[0,12,0],[0,19,59],[0,20,0]]
return = [true,false,true,false]
The store has two Monday phases. The half-open end at 20:00 is closed.
Example 2
openingHours = [[4,22,0,5,2,0],[6,22,0,0,2,0]]
queries = [[5,1,30],[5,2,0],[6,23,0],[0,1,0],[0,2,0]]
return = [true,false,true,true,false]
The first interval crosses Friday into Saturday. The second crosses the Sunday-to-Monday week boundary.

Constraints
0 <= openingHours.length, queries.length <= 100000.
Days are in [0,6], hours in [0,23], and minutes in [0,59].
An interval's start and end weekly times are different.
The schedule repeats every week in one timezone.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Convert every [day, hour, minute] to a single integer: day*1440 + hour*60 + minute. The week is 10080 minutes. For each interval, if start < end, mark [start, end). If end < start, it wraps, so mark [start, 10080) and [0, end). Starts never equal ends, so there's no full-week ambiguity. Then use a difference array of size 10081: add 1 at start, subtract 1 at end, prefix-sum it, and a query is true when the count at its minute is above 0. That's O(n + 10080 + q). Overlapping and touching intervals are handled for free because you test count > 0. The pitfall is the half-open end. Subtract at end, not end+1, or Example 1 fails at 20:00. Another trap is brute-force scanning intervals per query, which is 10^10 operations. If you blank on the wrap split during the live OA, StealthCoder can hand you the pattern.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Query Weekly Store Opening Hours 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Apple's OA.

Apple reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Query Weekly Store Opening Hours FAQ

What's the trick in Query Weekly Store Opening Hours?+

Flatten the week into minutes from 0 to 10079. Handle wrapping intervals by splitting them into two ranges, one to the end of the week and one from zero. Then precompute open status per minute with a difference array. Every query becomes a single array lookup.

How do I handle intervals that wrap past Sunday?+

If the end minute is less than the start minute, the interval crosses the week boundary. Add the range from start to 10080, then the range from 0 to end. Example 2's Sunday 22:00 to Monday 02:00 interval is exactly this case.

Why is the half-open end easy to get wrong?+

The store is open at start and closed at end. In a difference array, add 1 at start and subtract 1 at end, so end itself is not covered. Subtracting at end+1 makes the 20:00 query in Example 1 wrongly return true.

Do overlapping or touching intervals break the approach?+

No. The difference array sums coverage, so overlaps just push the count higher. Touching intervals, where one ends as another starts, net out correctly. Return true whenever the count at the query minute is greater than zero.

How do I prepare for this in 48 hours?+

Practice difference arrays and prefix sums on a small fixed domain. Write the time-to-minutes conversion and the wrap split from memory. Then test both examples by hand, especially the Saturday and Monday boundary queries. It's a short problem once the pattern clicks.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Apple.

OA at Apple?
Invisible during screen share
Get it