KLA Interview Question

Coding round: Famous Island problem solved using simple DFS