SoFi·Software Engineer·Technical Phone Screen
- Given a list of unsorted timestamps (in seconds) representing server requests, and a window length W, find the maximum number of requests that fall within any contiguous time window of length W. Return the count and optionally the start time of the best window.
- How would you extend this solution to handle weighted requests, where each request has a different weight, and you want to maximize total weight within the window instead of count?
- How would you adapt this approach for a streaming setting where timestamps arrive online and you can't sort them in advance?
“Sort first, then two pointers.”