Skip to content

Create Is Subsequence.md#7

Open
yakataN wants to merge 1 commit into
mainfrom
Is-Subsequence
Open

Create Is Subsequence.md#7
yakataN wants to merge 1 commit into
mainfrom
Is-Subsequence

Conversation

@yakataN
Copy link
Copy Markdown
Owner

@yakataN yakataN commented Jul 23, 2025

return True

seen = 0
for char_t in t:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

char_t は型と一瞬見間違えるので単に c でも良いと思います。

# 終了判定を挟む必要があり、そこをわかりやすくかけるかどうかでindexの扱いを変えたい
if len(s) == 0:
return True
seen = 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

seen という変数名から、どのような値が格納されているのか分かりづらく感じました。 step2 の s_index のほうが分かりやすく感じました。


if s[s_index] == t[t_index]:
return traverse(s_index + 1, t_index + 1)
else:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

再帰スッキリかけていて読みやすかったです。
強いて言えばここの else はなくてもいいですね

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.

4 participants