Each of the hashes have a finite (a-z, A-Z) number of possible characters, so the space used is O(1)

We iterate over s linearly, comparing constant length hashes at each iteration so each iteration is also O(1), so the runtime is O(n)

```
class Solution(object):
def findAnagrams(self, s, p):
"""
:type s: str
:type p: str
:rtype: List[int]
"""
res = []
n, m = len(s), len(p)
if n < m: return res
phash, shash = [0]*123, [0]*123
for x in p:
phash[ord(x)] += 1
for x in s[:m-1]:
shash[ord(x)] += 1
for i in range(m-1, n):
shash[ord(s[i])] += 1
if i-m >= 0:
shash[ord(s[i-m])] -= 1
if shash == phash:
res.append(i - m + 1)
return res
```

]]>Each of the hashes have a finite (a-z, A-Z) number of possible characters, so the space used is O(1)

We iterate over s linearly, comparing constant length hashes at each iteration so each iteration is also O(1), so the runtime is O(n)

```
class Solution(object):
def findAnagrams(self, s, p):
"""
:type s: str
:type p: str
:rtype: List[int]
"""
res = []
n, m = len(s), len(p)
if n < m: return res
phash, shash = [0]*123, [0]*123
for x in p:
phash[ord(x)] += 1
for x in s[:m-1]:
shash[ord(x)] += 1
for i in range(m-1, n):
shash[ord(s[i])] += 1
if i-m >= 0:
shash[ord(s[i-m])] -= 1
if shash == phash:
res.append(i - m + 1)
return res
```

]]>comparing constant length hashes at each iteration so each iteration is also O(1)

Can you explain a little bit why you're comparing two hashes here? What I see is comparison of two lists `phash`

and `shash`

and the time complexity of comparing two lists should be O(n).

he two lists sHash and pHash contain 123 elements

Why the two lists sHash and pHash contain 123 elements? How does this number (123) come from? Thanks!

]]>can anyone please help explain this line? Thanks! ]]>