two pointers
like BFS