Three Calls Within Three Seconds
Problem statement
timestamps are nondecreasing call times in milliseconds. After each call, return whether at least three calls including the current one lie within a window of at most 3000 milliseconds, meaning current time minus the third-most-recent qualifying time is at most 3000.
Function
threeCallsWithinWindow(timestamps: long[]) → boolean[]Examples
Example 1
timestamps = [0,1000,3000,7000,7500,8000]return = [false,false,true,false,false,true]Calls 0,1000,3000 fit exactly; later 7000,7500,8000 also fit.
Constraints
0 <= timestamps.length <= 2 * 10^5.- Timestamps are nondecreasing.