Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit de7879f

Browse files
Update 0139.单词拆分.md
1 parent d8c51b2 commit de7879f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎problems/0139.单词拆分.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ class Solution:
369369
dp = [False] * (n + 1) # dp[i] 表示字符串的前 i 个字符是否可以被拆分成单词
370370
dp[0] = True # 初始状态,空字符串可以被拆分成单词
371371

372-
for i in range(1, n + 1):
373-
for j in range(i):
372+
for i in range(1, n + 1):# 遍历背包
373+
for j in range(i):# 遍历单词
374374
if dp[j] and s[j:i] in wordSet:
375375
dp[i] = True # 如果 s[0:j] 可以被拆分成单词,并且 s[j:i] 在单词集合中存在,则 s[0:i] 可以被拆分成单词
376376
break

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /