Skip to content

Commit 6cc4b3c

Browse files
authored
Update max_product_subarray.py
1 parent 87eb373 commit 6cc4b3c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

dp/max_product_subarray.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ def max_product(nums):
3636
'''
3737

3838
def subarray_with_max_product(arr):
39-
''' arr is list of positive/negitive numbers '''
39+
''' arr is list of positive/negative numbers '''
4040
l = len(arr)
4141
product_so_far = max_product_end = 1
4242
max_start_i = 0
4343
so_far_start_i = so_far_end_i = 0
44-
all_negitive_flag = True
44+
all_negative_flag = True
4545

4646
for i in range(l):
4747
max_product_end *= arr[i]
48-
if arr[i] > 0: all_negitive_flag = False
48+
if arr[i] > 0: all_negative_flag = False
4949

5050
if max_product_end <= 0:
5151
max_product_end = arr[i]
@@ -56,7 +56,7 @@ def subarray_with_max_product(arr):
5656
so_far_end_i = i
5757
so_far_start_i = max_start_i
5858

59-
if all_negitive_flag:
59+
if all_negative_flag:
6060
print "max_product_so_far: %s, %s" % \
6161
(reduce(lambda x, y: x * y, arr), arr)
6262
else:

0 commit comments

Comments
 (0)