FB 电话

第一题:Merge K sorted list. 用priority queue解之。然后分析了Time complexity 和Space Complexity,面试官很满意。第二题:LeetCode上没有见过,似乎是和Inteval有关的变种:
给出很多interval,要求算出所有Overlap的interval的组合。
跟面试官讨论说interval用array来表示,并且假定输入是2D Array,先根据start time sort一下。然后iterate through 每个interval,看每个interval有哪些和它overlap的,加入到输出list。算是Easy Level

image
Just met the question in my last week’s interview. Seems like the variation of LC591, a hard one. The question asked to return the valid first N chars, like if N = 30, it is shown in the snapshot, if N is 2, none is valid, so return “”. If N is 7, return < p></ p>. Each char counts for 1.

I do not manage to solve it in the interview (performed well in the first round), so I got an additional interview. Does anyone know how to solve it?