Count connected islands using Union-Find | Uber Interview Question