由买买提看人间百态

topics

全部话题 - 话题: dprec
(共0页)
w****x
发帖数: 2483
1
DP解法:
dpRec[strlen(str)]
dpRec[i]: if true, previous character can split to words
for (int i = 0; i < strLen; i++)
for (int j = i; j >=0 && !dpRec[i]; j--)
dpRec[i] = true if dpRec[j] && isWord(str[j..i])
时间复杂度O(n^2)
(共0页)