Skip to content

Commit a098e33

Browse files
authored
Update contiguous-array.py
1 parent bae9594 commit a098e33

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Python/contiguous-array.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ def findMaxLength(self, nums):
2020
:rtype: int
2121
"""
2222
result, count = 0, 0
23-
lookup = {0: 0}
24-
23+
lookup = {0: -1}
2524
for i, num in enumerate(nums):
2625
count += 1 if num == 1 else -1
2726
if count in lookup:
28-
result = max(result, i+1 - lookup[count])
27+
result = max(result, i - lookup[count])
2928
else:
30-
lookup[count] = i+1
29+
lookup[count] = i
3130

3231
return result

0 commit comments

Comments
 (0)