problem
solution
當 window、need 兩個窗口一樣時,且兩個索引等於p字串的長度,此時可以確保s[l:r] 子字串等於字串p
1 | class Solution { |
- 可以用固定大小的vector 代替hash table
1 | class Solution { |
analysis
- time complexity
O(n)
- space complexity
O(1)
當 window、need 兩個窗口一樣時,且兩個索引等於p字串的長度,此時可以確保s[l:r] 子字串等於字串p
1 | class Solution { |
1 | class Solution { |
O(n)
O(1)