Peak Singles Day GMV Over a Fixed Minute Window
Last updated: November 29, 2026
Quick Overview
Given per-minute gross merchandise value (GMV) for a Singles' Day sale and a window length k, return the largest total GMV over any k consecutive minutes and the starting minute of that window (earliest on ties).
Alibaba
November 29, 20260
0
0 solved
Given per-minute gross merchandise value (GMV) for a Singles' Day sale and a window length k, return the largest total GMV over any k consecutive minutes and the starting minute of that window (earliest on ties).
A warm-up in the style of an Alibaba phone screen, framed around the real-time GMV dashboards Tmall runs during the 11.11 festival. The interviewer checks that you reach the O(n) sliding window instead of recomputing each window, and that you handle the boundary cases cleanly.
What the Interviewer Expects
- Clarify tie-breaking and what to return when k exceeds the series length
- Replace the O(nk) brute force with a running window sum
- Update the sum in O(1) per step by adding the new minute and dropping the oldest
- Track the best start index alongside the best sum
- State O(n) time and O(1) extra space
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return the top 3 non-overlapping k-minute windows?
- What changes if the window is defined by time (last 10 minutes of events) and events arrive at irregular timestamps?
- How would you maintain this live as each new minute's GMV streams in from many shards?
- What if GMV can be negative because refunds are netted in?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: a list gmv of non-negative numbers, one per minute, and an integer k. Output: (best_sum, start_index), earliest start on ties. If k is not in 1..n, return (0, -1) (confirm this with...
High-Level Design
Brute force sums each of the n-k+1 windows in O(k), so O(nk) total. Adjacent windows share k-1 minutes, so keep a running sum: add gmv[i] entering on the right, subtract gmv[i-k] leaving on th...