Skip to content

add: Unique Paths II#31

Open
rossy0213 wants to merge 1 commit intomainfrom
arai60-35
Open

add: Unique Paths II#31
rossy0213 wants to merge 1 commit intomainfrom
arai60-35

Conversation

@rossy0213
Copy link
Copy Markdown
Owner

@rossy0213 rossy0213 commented Jul 29, 2024

continue
}

dp[y][x] = dp[y - 1][x] + dp[y][x - 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.

ちょっとgoの命名習慣がわかってないですが、dpという変数名より中の内容を表した変数名の方がいいと思います。(num_pathsなど)

continue
}

if x == 0 && y == 0 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

この条件はループの外に出していい気がします。

あと、空行が少し多いですね。あまり読む助けになりません。

Comment on lines +97 to +107
if x == 0 {
dp[y][x] = dp[y - 1][x]
continue
}

if y == 0 {
dp[y][x] = dp[y][x - 1]
continue
}

dp[y][x] = dp[y - 1][x] + dp[y][x - 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.

ここ、まとめたほうが読みやすいかも知れません。

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://github.com/nittoco/leetcode/pull/27/files)

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.

3 participants