News for hackers. Stuff that matters.
Re:An Algorithm for Passing Programming Interviews (2020) by ALittleLight on Monday January 03, 2022 @04:19PM (#29787061)
What's the problem with a sliding window and the timestamp + count solution? lastTime is the timestamp of the last call. newTime is the timestamp of the incoming call. If newTime - lastTime > 60 seconds then you're good to proceed, set count to 1 change lastTime to newTime and go on. Otherwise, check whether count is less than n and proceed accordingly (incrementing count if so). This accomplishes the sliding window and rounding down to the last whole minute handles the fixed window - right?

There are no comments on this comment yet.