IBM Interview Question

islands questions like a dfs map