Pergunta de entrevista da empresa X

How to insert into sorted list of intervals?

Respostas da entrevista

Sigiloso

11 de out. de 2015

I failed in the details of the implementation. Provided a working O(n) solution after most of the 45 minutes elapsed. Interviewer made it clear from the beginning he wanted O(lg n), though. It's a tough thing to implement -- especially on the spot.

Sigiloso

20 de fev. de 2016

Honestly, I'd have done a binary search tree since insertion is O(log n). But then I need more details about the problem

Sigiloso

3 de abr. de 2016

The question is unclear. If the interval is already list of interval there is no way to get O(log N), because it need to scan from start to end to find the insertion point.