Skip to content

139. Word Break#37

Open
tom4649 wants to merge 2 commits intomainfrom
139.Word-Break
Open

139. Word Break#37
tom4649 wants to merge 2 commits intomainfrom
139.Word-Break

Conversation

@tom4649
Copy link
Copy Markdown
Owner

@tom4649 tom4649 commented Mar 29, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit sol1.py がTLEする方で、sol1_failed.py がパスする方に見受けられるので、ファイル名が逆かもしれません。

stripped_sub_strs = []
for word in wordDict:
if s.startswith(word):
stripped_sub_strs.append(s[len(word) :])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

str.strip() をするのかと変数名を見て思いましたが、いわゆる strip 処理を行っていなさそうなので、単に sub_strings でいいかなと思います。

if i == len_target:
return True
for word in wordDict:
if s.startswith(word, i) and can_break(i + len(word)):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

なるほど、部分文字列をわざわざ作らなくても startswith でいけるんですね、勉強になります 👀

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.

2 participants