695. Max Area of Islands#18
Open
tNita wants to merge 1 commit into
Open
Conversation
Manato110
reviewed
Apr 13, 2026
| def is_inside_island(i: int, j: int): | ||
| return 0 <= i < height and 0 <= j < width | ||
|
|
||
| def explorer_and_get_size_island(start: tuple[int]) -> int: |
There was a problem hiding this comment.
関数名の初めには動詞を使うことが多い気がします
explore_and_get_size_islandの方が文法的にも違和感がないです
Owner
Author
There was a problem hiding this comment.
なるほど、確かにそうですね。ご指摘ありがとうございます。
Manato110
reviewed
Apr 13, 2026
Comment on lines
+170
to
+179
| i, j = stack.pop() | ||
| if not is_inside_island(i, j) or grid[i][j] == self.WATER or visited[i][j]: | ||
| continue | ||
| visited[i][j] = True | ||
| area_size += 1 | ||
| stack.append((i - 1, j)) | ||
| stack.append((i + 1, j)) | ||
| stack.append((i, j - 1)) | ||
| stack.append((i, j + 1)) | ||
| return area_size |
There was a problem hiding this comment.
Manato110/LeetCode-arai60#17 (comment)
私自身このようなコメントを受けたのですが、
i, jは行列に使うことはあれど、座標に用いられることはあまりないようです。
Owner
Author
There was a problem hiding this comment.
なるほどです。
(r, c) (row, col) あたりを使うと自然になると思います。
確かにこっちの方がわかりやすいですね。
Manato110
reviewed
Apr 13, 2026
Comment on lines
+181
to
+187
| max_are_size = 0 | ||
| for i in range(height): | ||
| for j in range(width): | ||
| if not visited[i][j] and grid[i][j] == self.LAND: | ||
| area_size = explorer_and_get_size_island((i, j)) | ||
| max_are_size = max(max_are_size, area_size) | ||
| return max_are_size |
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
この問題: Max Area of Island
次の問題: Word Ladder
※ Number of Connected Components in an Undirected Graph は有料問題なので一旦スキップ