ByteDance interview question

Bfs question, binary search question