Skip to content

695. Max Area of Island - #56

Open
skypenguins wants to merge 1 commit into
mainfrom
leetcode/arai60/problem-695
Open

695. Max Area of Island#56
skypenguins wants to merge 1 commit into
mainfrom
leetcode/arai60/problem-695

Conversation

@skypenguins

Copy link
Copy Markdown
Owner

695. Max Area of Island

次回予告: 776. Split BST

@skypenguins skypenguins self-assigned this Jul 26, 2026
Comment thread memo.md

### 正答
- 以下の正答を読んで `200. Number of Islands` の時のDFSの方法で解いていれば、素直に面積を求められたかもしれないと思った。
- Union-Findは実装が複雑になりがち

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

自分は面接本番で Union Find をバグなく書ける自信がありません。仮に面接で Union Find を使いたい場面が出てきたら、「Union Find の実装がすでにあるという仮定のものとで進めて良いですか?」と面接官に尋ねると思います。ただし、経路の圧縮、ランクまたはサイズでどちらを親にするか、時間計算量がアッカーマン関数の逆関数、といったところは軽く触れると思います。

Comment thread memo.md
visited = [[False] * num_cols for _ in range(num_rows)]

def area_of_island(start_row, start_col):
to_visit_cells = [(start_row, start_col)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to_visit_cells は英語として語順が不自然に感じました。 cells_to_visit のほうが良いと思います。

Comment thread memo.md
visited = [[False] * num_cols for _ in range(num_rows)]

def area_of_island(row, col):
if (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iterative DFS で書かれたように、数直線上に一直線上になるように書いたほうが、読み手にとって読みやすくなると思います。

if not (
    0 <= row < num_rows
    and 0 <= col < num_cols
    and not visited[row][col]
    and gird[row][vol] == LAND):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants