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:
- insert(x), which will take integer x and insert it into your data structure.
- 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)


