Skip to content

63. Unique Paths II#27

Open
n6o wants to merge 1 commit intomainfrom
unique-paths-ii
Open

63. Unique Paths II#27
n6o wants to merge 1 commit intomainfrom
unique-paths-ii

Conversation

@n6o
Copy link
Copy Markdown
Owner

@n6o n6o commented Mar 17, 2026

今回の問題

Unique Paths II - LeetCode

使用言語

Python

rows = len(obstacleGrid)
columns = len(obstacleGrid[0])

pathCountMatrix = [[0] * columns for _ in range(rows)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

こちらのコメントをご参照ください。
tNita/arai60#3 (comment)

rows = len(obstacleGrid)
columns = len(obstacleGrid[0])

pathCountMatrix = [[0] * columns for _ in range(rows)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 次元配列であることは定義から明らかなため、変数名に Matrix と入れなくても良いと思います。

if not obstacleGrid or not obstacleGrid[0]:
return 0

rows = len(obstacleGrid)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

自分は num_rows num_columns と名付けるのですが、趣味の範囲だと思います。

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.

ありがとうございます。
そちらのほうが使いやすいと思いました。

rows = len(obstacleGrid)
columns = len(obstacleGrid[0])

pathCountMatrix = [[0] * columns for _ in range(rows)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

経路長を 1 行分のみ保持する書き方もあります。興味があれば探してみてください。

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