TikTok Interview Question

A bfs grid island algorithm question