Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private bool IsBreakableIntoMultiple(string word)
- {
- var dp = new bool[word.Length + 1];
- var len = word.Length;
- dp[^1] = true;
- for (int j = len; j > 0; j--)
- {
- for (int i = 0; i < j; i++)
- {
- // if (i + j > maxWordInDic)
- // {
- // continue
- // }
- var checkWord = word.Substring(i, j - i);
- if (dp[j] && Dictionary.Contains(checkWord))
- {
- dp[i] = true;
- j = i + 1; // +1 since loop will j--
- break;
- }
- }
- }
- return dp[0];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement