Uber Interview Question

DS & Algorithms : countIsland problem