Word Break Problem?
bool WordBreak(string s, HashSet<string> wordDict)
{
bool[] dp = new bool[s.Length + 1];
dp[0] = true;
for (int i = 1; i <= s.Length; i++)
{
for (int j = 0; j < i; j++)
{
if (dp[j] && wordDict.Contains(s.Substring(j, i - j)))
{
dp[i] = true;
break;
}
}
}
return dp[s.Length];
}
Explanation:
DP to check if substring can be segmented using dictionary words.
Follow on: