Microsoft | Phone | Maintaining state of integers in a stream
Anonymous User
278

Given a stream of integers where probability of a smaller number being first in stream is more than probability of larger number in stream.

Implement a method that returns true if you have already seen that element in stream otherwise return false.

eg. stream could look like 1,2,3,5,6,11,7,3......
more examples - 3,4,1,2,5,9,22,12


I explained using a hashset but that solution was not viable because of the space requirement.
I don't think I handled this question well. So would love people's opinion on it.

  • James
Comments (2)