62. Unique Paths#9
Conversation
| using namespace std; | ||
|
|
||
| // <時間> | ||
| // 10分 |
There was a problem hiding this comment.
10分で書けているなら、この問題はいいでしょう。
CPython の comb のコードを読んでいる人もいました。
| public: | ||
| int uniquePaths(int m, int n) { | ||
| vector<vector<int>> num_paths(m, vector<int>(n)); | ||
| for (int i = 0; i < m; ++i) num_paths[i][0] = 1; |
There was a problem hiding this comment.
僕はこちらで行かせていただきます(チームの時はチームに従います)
https://google.github.io/styleguide/cppguide.html#Formatting_Looping_Branching
For historical reasons, we allow one exception to the above rules: the curly braces for the controlled statement or the line breaks inside the curly braces may be omitted if as a result the entire statement appears on either a single line (in which case there is a space between the closing parenthesis and the controlled statement) or on two lines (in which case there is a line break after the closing parenthesis and there are no braces).
// OK - braces are optional in this case. if (x == kFoo) return new Foo();
There was a problem hiding this comment.
ちなみに↑のHistorical reasonsってどういう意味か聞いてもよいですか?
昔はぶら下がりifがたくさん使われてて、それを修正するのが大変だから、ぐらいの意味ですか?
(そして現代だとワンライナーぶら下がりifを新しく作るのはあまり主流ではない、という)
There was a problem hiding this comment.
書いた人に聞かないと分かりません。どっかのメーリングリストでやりとりがおこなわれておりました。
ただ、昔、慣習的に使われていた、(から好ましくないが慣れて読める人も多いので許す)くらいの温度感でしょう。
現代的な言語、たとえば Rust や Go や Swift などは {} が必要です。いらないのは C C++ Java などですね。
注意
ファイルが複数ある場合、<番号>.cppの<番号>が最も大きいものが最新版です!
最新版のみレビューお願いします!(もちろん過去のものをレビューしていただいても構いませんmm)
問題
https://leetcode.com/problems/unique-paths/description/?envType=problem-list-v2&envId=xo2bgr0r