I never met this before, either..... Any idea please? Thanks!
Given a streaming data of the form (timestamp, value), find the maximum value in the stream in the last X seconds.
Assume time is monotonically increasing.
Assume time is in the order of seconds.
max_value() function finds the max in the last X seconds.
StreamProcessor(5) // last 5 seconds
set_value(0, 5)
set_value(1, 6)
set_value(2, 4)
max_value(3) = 6 -> always the current time
class StreamProcessor:
def init(self, x):
self.x = x
def set_value(self, t, v):
pass
def max_value(self, cur_t):
pass