Skip to content

Conversation

nittoco
Copy link
Owner

@nittoco nittoco commented Jun 3, 2024

URL: https://leetcode.com/problems/is-subsequence/
Given two strings s and t, return true if s is a subsequence of t, or false otherwise.

A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not).

https://leetcode.com/problems/is-subsequence/
Given two strings s and t, return true if s is a subsequence of t, or false otherwise.

A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not).
```


- while elseを使う(なんとなく聞いたことあるくらいで、よく把握していないので調べた) これは全然慣れない。結局コードを参照しながら書いて時間がかかった。慣れといた方がいいのか?
Copy link

Choose a reason for hiding this comment

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

私も、Python native じゃないので、while else 慣れない(し自然さは感覚がない)んですが、CPython のコードなどを見ていると、たまに出てきますね。
https://github.com/python/cpython/blob/2e0aa731aebb8ef3d89ada82f5d39b1bbac65d1f/Modules/itertoolsmodule.c#L2625

Copy link
Owner Author

Choose a reason for hiding this comment

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

コード例ありがとうございます。
見てみましたが、自分にとっては複雑でまだ処理が終えてないのでまた時間がある時に見てみます

Copy link

@fhiyo fhiyo left a comment

Choose a reason for hiding this comment

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

いいと思います。丁寧に書かれていて勉強になりました。

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.

3 participants