原文:Leetcode: Number of Islands

DFS的Flood Fill方法, 不使用額外visited數組,但是用 變成 表示visited的方法 復雜度 時間 O NM 空間 O max N,M 遞歸棧空間 Union Find: Quick Union follow up是找最大島的面積,想法是設置兩個全局變量 maxArea, area, area負責記錄每個島的面積,上面代碼第 行每次遇到 就置為 ,然后在recursion里面 ...

2015-04-11 05:20 0 1999 推薦指數:

查看詳情

[LeetCode] Number of Islands

Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting ...

Wed Apr 08 20:37:00 CST 2015 0 2918
[LeetCode] Number of Islands II

Problem Description: A 2d grid map of m rows and n columns is initially filled with water. We may p ...

Sun Nov 15 04:55:00 CST 2015 0 6974
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM