这道题和number of islands很像,本质上是无向图的连通性问题。首先构建adjacent map, 然后dfs数不连通的islands.

results matching ""

    No results matching ""