TikTok Interview Question

Two graph problems, using bfs.