ByteDance Interview Question

A coding question on floodfill, BFS.