Skip to content

141. Linked List Cycle.md#1

Open
X-XsleepZzz wants to merge 5 commits into
mainfrom
lilnoahhh-patch-1
Open

141. Linked List Cycle.md#1
X-XsleepZzz wants to merge 5 commits into
mainfrom
lilnoahhh-patch-1

Conversation

@X-XsleepZzz
Copy link
Copy Markdown
Owner

@X-XsleepZzz X-XsleepZzz commented Dec 17, 2024

141. Linked List Cycle
問題文:
Given head, the head of a linked list, determine if the linked list has a cycle in it.

There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to. Note that pos is not passed as a parameter.

Return true if there is a cycle in the linked list. Otherwise, return false.

次回問題予告:
142. Linked List Cycle II

Comment thread test.md Outdated

"""python
if node is in visited:"""
と書いたらsyntax errorはきだした。whileと違ってifの中にinは使わない。
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is も in も演算子です。
https://docs.python.org/3/library/operator.html

Comment thread test.md
オーバーロードとは?
「プログラミングにおいては同じ名前の関数や演算子などを複数定義し、それを利用する際に引数などに応じて使い分けられる仕組みのこと。例えば、+という演算子が数字同士では加算するのに対して、文字列同士では文字列の結合という結果を出力する。」(https://www.ntt-west.co.jp/business/glossary/words-00735.html)

「==, !=は特殊メソッド__eq__, __ne__でオーバーロード可能であり、自由にカスタマイズできる。」→__eq__,__ne__というもので==,!=どっちも表現できるということ?
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
Owner Author

Choose a reason for hiding this comment

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

pythonのクラスや間数の理解曖昧でした。参考になります!ありがとうございます

Copy link
Copy Markdown

@t0hsumi t0hsumi left a comment

Choose a reason for hiding this comment

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

良さそうに思います。
蛇足ですが、ここでよく参照されるコーディングスタイルとして、PEP8に加えてGoogle python style guideがあります。

@katataku
Copy link
Copy Markdown

中身の話じゃないのですが、
コードブロックがうまくかけていないようです。コードを囲むのは「バッククォート3つ」です。(ダブルクオートを使っちゃってそうです。)

https://blog.katsubemakito.net/articles/github-markdown-syntaxhighlighting?utm_source=chatgpt.com

@X-XsleepZzz
Copy link
Copy Markdown
Owner Author

良さそうに思います。 蛇足ですが、ここでよく参照されるコーディングスタイルとして、PEP8に加えてGoogle python style guideがあります。

Google python style guide初めて知りました!これも使って学習に役立てます。ありがとうございます

@X-XsleepZzz
Copy link
Copy Markdown
Owner Author

中身の話じゃないのですが、 コードブロックがうまくかけていないようです。コードを囲むのは「バッククォート3つ」です。(ダブルクオートを使っちゃってそうです。)

https://blog.katsubemakito.net/articles/github-markdown-syntaxhighlighting?utm_source=chatgpt.com

ありがとうございます!修正いたしました

Comment thread test.md

それなら答えのコードwhile fast and fast.nextはwhile fast is None and fast.next is Noneと書いたほうがよさそう。

マルチスレッドとは、一つのコンピュータープログラムを実行する際に、アプリケーションのプロセス(タスク)を複数のスレッドに分けて並行処理する流れのことです。マルチスレッドの対義語はシングルスレッドで、ソースコードの上から順に一つの処理を行ないます。
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ネイティブスレッドと Python のスレッドの違いに注意が必要だと思います。

https://ja.wikipedia.org/wiki/%E3%82%B9%E3%83%AC%E3%83%83%E3%83%89_(%E3%82%B3%E3%83%B3%E3%83%94%E3%83%A5%E3%83%BC%E3%82%BF)
https://ja.wikipedia.org/wiki/%E3%82%B0%E3%83%AD%E3%83%BC%E3%83%90%E3%83%AB%E3%82%A4%E3%83%B3%E3%82%BF%E3%83%97%E3%83%AA%E3%82%BF%E3%83%AD%E3%83%83%E3%82%AF

ただし、 Python 3.13 からは GIL を無効化することができます。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ありがとうございます!違いに気をつけて参照してくれた文章を読んでみます

Comment thread test.md
Comment on lines +69 to +72
「上の set を使ったコードが書けた場合、普通はできます。
上の set を使ったコードが書けなかった場合、一緒に働くことが困難です。
というわけで、set を使えるかを判定している出題です。」(odaさんの発言より)
あーsetを扱えることを見るための問題だったのか。今後もsetを使うのは重要っぽい
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

コメント遅れてすいません
ここの部分は自分も参考になりました。ありがとうございます

@X-XsleepZzz X-XsleepZzz changed the title 141. Linked List Cycle 141. Linked List Cycle.md Jan 7, 2025
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.

6 participants