Trains the technique from
LeetCode 2251Number of Flowers in Full BloomThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A night market runs on a single long clock measured in whole minutes. stalls[i] = [open_i, shut_i] says that stall i is trading during every minute from open_i to shut_i, and both of those minutes count: the stall is trading at minute open_i and still trading at minute shut_i.
arrivals[j] is the minute at which visitor j walks in.
Return a list answer where answer[j] is the number of stalls trading at minute arrivals[j]. Keep the answers in the same order as arrivals. Several visitors may arrive in the same minute.
Example 1
At minute 3 only the first stall has opened. At minute 7 the first and second are both trading. At minute 8 the first has shut but the second and third are trading. At minute 9 only the second is left, and at minutes 10 and 2 nothing is trading.
Example 2
The single stall opens and shuts within minute 4, so it is trading for the visitor who arrives then and for nobody else.
Example 3
Minute 4 falls inside all three trading spans. Minute 6 is the last minute of the first stall only, minute 2 is the first minute of the first stall only, and minute 1 is before every stall opens.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def stalls_open(stalls: list[list[int]], arrivals: list[int]) -> list[int]:public int[] stallsOpen(int[][] stalls, int[] arrivals)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.