695. Max Area of Island - #18
Conversation
| (-1, 0) | ||
| ] | ||
| def maxAreaOfIsland(self, grid: List[List[int]]) -> int: | ||
| height = len(grid) |
There was a problem hiding this comment.
個人的には、 width/height は x/y とセットで使われる印象があります。 row/col とセットで使うのであれば、自分なら num_rows/num_cols と名付けると思います。
There was a problem hiding this comment.
ありがとうございます。
一つ前の問題でいただいた指摘とも重なるところがありますね。
#17 (comment)
確かに何とセットにしているかを明示したいかによっても変数名を決めるべきですね。以降実践します。
| return 0 | ||
| grid[row][col] = self.VISITED | ||
| return ( | ||
| 1 + sum_current_area(row+1, col) |
There was a problem hiding this comment.
こちらのコメントをご参照ください。
mt2324/leetcode#2 (comment)
There was a problem hiding this comment.
ありがとうございます。
存じなかったので勉強になりました。
二項演算子の両側にスペースが空いている空いていないものが混在しており、読み手にとってノイズになりそう
確かにそうですね。
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.
キーワード変数やデフォルト値を関数に渡すときは空けないなど、一部例外があるのも興味深いと思いました。
| WATER = 0 | ||
| LAND = 1 | ||
| DIRECTIONS = [ | ||
| (0,1), |
There was a problem hiding this comment.
, のあとにスペースが空いているものと空いていないものとが混在しているのが気になりました。空けるほうに統一することをお勧めいたします。
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.
There was a problem hiding this comment.
ありがとうございます。存じ上げませんでした。
確かにその方が読む時にノイズが少なくなりそうですね。以降実践していきます。
https://leetcode.com/problems/max-area-of-island/description/
Next: https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/description/