Skip to content

Commit b54ad03

Browse files
committed
One final test for the night
1 parent 490892d commit b54ad03

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def hasAllCodes(self, s: str, k: int) -> bool:
3+
found = set()
4+
current = int(s[:k], 2)
5+
found.add(current)
6+
for i in range(k, len(s)) :
7+
current = (2 * current) % (2 ** k) + (ord(s[i]) - ord('0'))
8+
found.add(current)
9+
10+
return len(found) == 2 ** k

0 commit comments

Comments
 (0)