发一个狗家onsite, 顺便求一些最优解答
- text editor, movecursorright(), movecursorleft(), insertcharacter(), backspace(). Follow up, undo
- valida parenthesis, 给一个N,代表parenthesis的个数,求所有valid结果
- lowest common ancestor, 给一堆nodes,包含node.mom, node.dad. 求找到两个noodeA, nodeB有没有血缘关系。 (求个最优解法, 我答得是找到所有A的ancestor放到map里, 然后recursive搜索B的ancestor,如果在map里就有关系。感觉不是最优)
- triple booking, boss的schedule是listofinterval[10:00-12:00, 9:00-11:00, 11:00-12:00], 可能有许多重叠。 然后你有only 1 interval [start - end], 求你的interval跟boss的schedule有没有triple booking出现 (boss本身triple booking的不算)。 也求个最优解吧