Skip to content

695 max area of island#19

Open
MA-yo-TA wants to merge 2 commits into
mainfrom
695-Max-Area-of-Island
Open

695 max area of island#19
MA-yo-TA wants to merge 2 commits into
mainfrom
695-Max-Area-of-Island

Conversation

@MA-yo-TA

Copy link
Copy Markdown
Owner

@jjysogfy jjysogfy left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

見やすかったです。少しだけ気になったことをコメントしてみました。


class Solution:
def maxAreaOfIsland(self, grid: list[list[NodeType]]) -> int:
num_rows = len(grid)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ただの感想ですが、こうして、変数の使用より宣言が先の行にあると見やすいです。

def maxAreaOfIsland(self, grid: list[list[NodeType]]) -> int:
num_rows = len(grid)
num_columns = len(grid[0])
seen_nodes: set[tuple[int, int]] = set()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

単語nodeを変数名に使っていますが、個人的には、cell, position, coordinateあたりの単語のほうが見慣れていて、引っかかりを感じにくいです。
ノードと言われたときは、このコードはBFSをしていて、そのノードは(row, column)だ、と考える必要があるからだと思います。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ありがとうございます。おっしゃる通り cell とかの方がいいですね。

node はグラフ的な頭に引っ張られた命名になっちゃってますね。

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants