Skip to content

392. Is Subsequence#57

Open
ryosuketc wants to merge 1 commit intomainfrom
392_is_subsequence
Open

392. Is Subsequence#57
ryosuketc wants to merge 1 commit intomainfrom
392_is_subsequence

Conversation

@ryosuketc
Copy link
Owner


class Solution3:
def isSubsequence(self, s: str, t: str) -> bool:
chat_to_indices = defaultdict(list)

Choose a reason for hiding this comment

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

char_to_indicesのtypoですかね?

* t の char を consume していって、s の最後まで到達できれば ok というのはすぐに考えた
* Counter みたいな解法 (anagram 的な) も一瞬考えてみたけど subsequence で、出現回数だけでなく順番も大事だから解けないと思った。
* 4:00 くらいで `SolutionWA` 書いた。
* 脳内で走らせてみて動くと思ったので submit したが WA。s が空文字列のときを考えていなかった。
Copy link

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