Open
Conversation
oda
reviewed
Dec 9, 2025
| @@ -0,0 +1,11 @@ | |||
| ### step1 | |||
|
|
|||
| グラフのサイクル検出アルゴリズムで解こうとしたが、実装が主いつなかったので、ChatGPTに提示されたフロイドの循環検出アルゴリズム(https://note.com/rhayahi/n/n7fc11c09fec6)で解いた。 | |||
There was a problem hiding this comment.
Owner
Author
There was a problem hiding this comment.
フロイドのうさぎとかめは知らなかったのですが、setの方での実装をsolution2.cppというファイルで書き直しておきました。
| class Solution { | ||
| public: | ||
| bool hasCycle(ListNode *head) { | ||
| if (head == nullptr) return false; |
There was a problem hiding this comment.
この行はあってもいいですが、なくてもいいですね。(意図としては、よしあしがあるので書いても書かなくてもいいが、動作が変わるかを考えておきましょうということです。)
Owner
Author
There was a problem hiding this comment.
動作がどう変わるかは考えるようにします。
Apo-Matchbox
reviewed
Dec 9, 2025
|
|
||
| ### step2 | ||
|
|
||
| L11の部分をhead == nullptrに書き直した。 |
There was a problem hiding this comment.
step2で参照したreferenceやGitHubなどリンクを貼っておくと後の学習に役立つと思います。
スタイルなどを参照したい時は下記も役に立つかと思います。あくまで参考ですが、一つ基準があると良いそうです。
https://google.github.io/styleguide/cppguide.html
Owner
Author
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/linked-list-cycle/description/
次に解く問題:https://leetcode.com/problems/linked-list-cycle-ii/description/