Open
Conversation
potrue
reviewed
Feb 19, 2026
| for (int r = 0; r < num_row; r++) { | ||
| for (int c = 0; c < num_col; c++) { | ||
| if (obstacleGrid[r][c] == kObstacle) { | ||
| unique_paths[r][c] = 0; |
Owner
Author
There was a problem hiding this comment.
動きますね。自分は入れておいた方がわかりやすいかなと思って入れました。
oda
reviewed
Mar 14, 2026
| 例外処理。そもそもベクトルが blank の場合への対処と、ある行すべてに障害物があった場合に打ち切り処理を入れる方法。 | ||
|
|
||
| - [参照](https://github.com/irohafternoon/LeetCode/pull/37/files)。 | ||
| - 後者のケースってあんまり思いつかない。この処理を入れることによる計算の効率化の幅と、可読性の低下幅と、どっちが大きいだろう?都度判定を入れることになるので計算の効率化もそこまでされないのではと思う。 |
There was a problem hiding this comment.
「打ち切り処理を入れるか」といったことは結局は、そのプログラムがどのようなものを扱うかの分布との兼ね合いです。
たとえば、ライブラリーのソート関数は、意外とすでにソート済みが入力に来ることが多い、と判断されて、すでにソート済みの場合は何もしない処理が入っていたりすることがあります。しかし、これは分布を試して確認しないことにはなんとも言えない話です。
なので、とりあえず、シンプルに作って、必要性との兼ね合いで後から入れることが割と好まれるのですね。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
https://leetcode.com/problems/unique-paths-ii/
次に解く問題
198. House Robber