Skip to content

695. Max Area of Island - #18

Open
kazizi55 wants to merge 1 commit into
mainfrom
695-max-area-of-island
Open

695. Max Area of Island#18
kazizi55 wants to merge 1 commit into
mainfrom
695-max-area-of-island

Conversation

@kazizi55

Copy link
Copy Markdown
Owner

(-1, 0)
]
def maxAreaOfIsland(self, grid: List[List[int]]) -> int:
height = 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.

個人的には、 width/height は x/y とセットで使われる印象があります。 row/col とセットで使うのであれば、自分なら num_rows/num_cols と名付けると思います。

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.

ありがとうございます。

一つ前の問題でいただいた指摘とも重なるところがありますね。
#17 (comment)

確かに何とセットにしているかを明示したいかによっても変数名を決めるべきですね。以降実践します。

return 0
grid[row][col] = self.VISITED
return (
1 + sum_current_area(row+1, 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.

こちらのコメントをご参照ください。
mt2324/leetcode#2 (comment)

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.

ありがとうございます。
存じなかったので勉強になりました。

二項演算子の両側にスペースが空いている空いていないものが混在しており、読み手にとってノイズになりそう

確かにそうですね。

Never use spaces around = when passing keyword arguments or defining a default parameter value, with one exception: when a type annotation is present, do use spaces around the = for the default parameter value.

キーワード変数やデフォルト値を関数に渡すときは空けないなど、一部例外があるのも興味深いと思いました。

https://google.github.io/styleguide/pyguide.html#36-whitespace:~:text=Never%20use%20spaces%20around%20%3D%20when%20passing%20keyword%20arguments%20or%20defining%20a%20default%20parameter%20value%2C%20with%20one%20exception%3A%20when%20a%20type%20annotation%20is%20present%2C%20do%20use%20spaces%20around%20the%20%3D%20for%20the%20default%20parameter%20value.

WATER = 0
LAND = 1
DIRECTIONS = [
(0,1),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

, のあとにスペースが空いているものと空いていないものとが混在しているのが気になりました。空けるほうに統一することをお勧めいたします。

https://google.github.io/styleguide/pyguide.html#s3.6-whitespace

Do use whitespace after a comma, semicolon, or colon, except at the end of the line.

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.

ありがとうございます。存じ上げませんでした。
確かにその方が読む時にノイズが少なくなりそうですね。以降実践していきます。

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