-
Notifications
You must be signed in to change notification settings - Fork 0
141. Linked List Cycle.md #1
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
step1
とりあえず完成版
test.md
Outdated
|
||
"""python | ||
if node is in visited:""" | ||
と書いたらsyntax errorはきだした。whileと違ってifの中にinは使わない。 |
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.
is も in も演算子です。
https://docs.python.org/3/library/operator.html
オーバーロードとは? | ||
「プログラミングにおいては同じ名前の関数や演算子などを複数定義し、それを利用する際に引数などに応じて使い分けられる仕組みのこと。例えば、+という演算子が数字同士では加算するのに対して、文字列同士では文字列の結合という結果を出力する。」(https://www.ntt-west.co.jp/business/glossary/words-00735.html) | ||
|
||
「==, !=は特殊メソッド__eq__, __ne__でオーバーロード可能であり、自由にカスタマイズできる。」→__eq__,__ne__というもので==,!=どっちも表現できるということ? |
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.
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.
pythonのクラスや間数の理解曖昧でした。参考になります!ありがとうございます
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.
良さそうに思います。
蛇足ですが、ここでよく参照されるコーディングスタイルとして、PEP8に加えてGoogle python style guideがあります。
中身の話じゃないのですが、 https://blog.katsubemakito.net/articles/github-markdown-syntaxhighlighting?utm_source=chatgpt.com |
Google python style guide初めて知りました!これも使って学習に役立てます。ありがとうございます |
ありがとうございます!修正いたしました |
|
||
それなら答えのコードwhile fast and fast.nextはwhile fast is None and fast.next is Noneと書いたほうがよさそう。 | ||
|
||
マルチスレッドとは、一つのコンピュータープログラムを実行する際に、アプリケーションのプロセス(タスク)を複数のスレッドに分けて並行処理する流れのことです。マルチスレッドの対義語はシングルスレッドで、ソースコードの上から順に一つの処理を行ないます。 |
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.
ネイティブスレッドと 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 を無効化することができます。
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.
ありがとうございます!違いに気をつけて参照してくれた文章を読んでみます
「上の set を使ったコードが書けた場合、普通はできます。 | ||
上の set を使ったコードが書けなかった場合、一緒に働くことが困難です。 | ||
というわけで、set を使えるかを判定している出題です。」(odaさんの発言より) | ||
あーsetを扱えることを見るための問題だったのか。今後もsetを使うのは重要っぽい |
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.
コメント遅れてすいません
ここの部分は自分も参考になりました。ありがとうございます
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