Solve tree, graph, sliding-window problems | Google Interview Question