Skip to content

Commit eaba103

Browse files
authored
Update README.md
1 parent efc0388 commit eaba103

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

note/030/README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Output: []
2727
**Tags:** Hash Table, Two Pointers, String
2828

2929

30-
## 思路
30+
## 思路 0
31+
遍历string的字符串,挨个匹配,O(n*wordLength)
3132

3233
1. 使用HashMap来保存L中所有的字串。
3334

@@ -89,6 +90,27 @@ class Solution {
8990
}
9091
}
9192

93+
```
94+
95+
## 思路 1
96+
通过滑动窗口的思维,窗口大小为words数组的1个单位。
97+
98+
An O(N) solution with detailed explanation
99+
100+
1. travel all the words combinations to maintain a window
101+
102+
2. there are wl(word len) times travel
103+
104+
3. each time, n/wl words, mostly 2 times travel for each word
105+
106+
4. one left side of the window, the other right side of the window
107+
108+
5. so, time complexity O(wl * 2 * N/wl) = O(2N)
109+
110+
111+
```java
112+
113+
92114
```
93115

94116

0 commit comments

Comments
 (0)