Millennium Interview Question

Binary search question then dp with bfs