Google Phone Interview | SDE1 | Stream of Tuples

Given a stream (time t, string s), find a pattern where string 'foo' occurs within time t of 10 seconds when string 'bar' occurs.

Because the assumption is a stream of tuples coming in one by one infinitely,
input: ((1, 'foo'),(3, 'foo'), (4, 'fee'), (5,'har'),(6, 'bar'))
out: ((1, 'foo'),(3,'foo'),(6,'bar'))

Comments (7)