-
Notifications
You must be signed in to change notification settings - Fork 0
6. Zigzag Conversion #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
そういえば、これで60問解き終わりました。今までレビューしてくださった方ありがとうございます🙏 |
| } | ||
| return result; | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
各行でindexを計算するの面白いですね。ですがやや複雑で、個人的には一番上に書かれたパターンが読みやすいと思いました。
| } | ||
| } | ||
| } | ||
| next_row: ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ラベルのインデントは一番浅い位置にする印象があります(例:CPython)。ただスタイルガイドに記載はないようです。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ラベルのインデントスタイルは意識していませんでした。ありがとうございます。
| result.push_back(s[index]); | ||
| index += cycle_length; | ||
| } else { | ||
| goto next_row; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goto はあまり見ないように思います。理由として、濫用するとスパゲティコードになりやすいからだと思います。かなり深い最内周ループから関数の最後に飛びたいといった極めて限定的な個所では、使う場合もあるかもしれません。原則避けたほうが無難だと思います。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goto を使いたくなったら、大抵、もう少し整えられます。
たとえば、この場合だったら while (true) を関数にして、goto を return にしたほうがいいのではないでしょうか。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
あ、たしかにその方がよさそうですね。ありがとうございます。
ryosuketc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
特に追加のコメントはありませんでしたが、60 問おつかれさまでした!
https://leetcode.com/problems/zigzag-conversion/