Approach 1: Bold boolean array
- Time:O(|\texttt{s}|^2 \cdot \Sigma |\texttt{words[i]}|)
- Space:O(|\texttt{s}|)
C++ |
---|
|
JAVA |
---|
|
Python |
---|
|
Approach 2: Trie
- Time:O(|\texttt{s}|^2 + \Sigma |\texttt{words[i]}|)
- Space:O(|\texttt{s}| + |\texttt{words}|)
C++ |
---|
|
JAVA |
---|
|
Python |
---|
|
Approach 3: Reduce to 56. Merge Intervals
- Time:O(|\texttt{s}|^2 \cdot \Sigma |\texttt{words[i]}|)
- Space:O(|\texttt{s}| + |\texttt{words}|)
C++ |
---|
|