Given a string A and a dictionary of n words B, find out if A can be segmented into a space-separated sequence of dictionary words.
- Time : O(n^2)
Space : O(b)
dnc solution
c++
1 | class Solution { |
- Time : O(2^n)
Space : O(b)
trie solution
c++
1 | struct Trie { |