[Google]: Maximum Stream Value Less than a Threshold

Anonymous User
914
Mar 16, 2022
Mar 16, 2022

I was asked to implement the following data structure in a recent interview with Google.

You need to implement a data structure that supports the following operations:

  1. insert(x), which will take integer x and insert it into your data structure.
  2. query(x), which will return the maximum value strictly less than x that we've encountered so far.

Unfortunately, I couldn't figure out a great solution during the interview. Could someone please tell me the correct approach to this problem so that I can learn?

Thanks

Comments (6)