Skip to content

Commit

Permalink
max_sub_array.py: Add Maximum Subarray algorithm
Browse files Browse the repository at this point in the history
The math module has been removed

closes NITSkmOS#215
  • Loading branch information
halderjoydeep committed Oct 4, 2018
1 parent 1c78fbe commit 7526574
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions maximum_subarray/max_sub_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
https://en.wikipedia.org/wiki/Maximum_subarray_problem
"""

import math # for using the infinity value we have imported math module


# @param A is array
# @param low is lowest index
Expand Down Expand Up @@ -44,7 +42,7 @@ def max_sub_array(A, low, high):
def cross_sub_array(A, low, mid, high):
# @param lsum is left sum

lsum = -math.inf
lsum = -10000
sum = 0
maxl = mid
maxr = mid + 1
Expand All @@ -55,7 +53,7 @@ def cross_sub_array(A, low, mid, high):
maxl = i

# @param rsum is right sum
rsum = -math.inf
rsum = -10000
sum = 0
for i in range(mid + 1, high + 1):
sum = sum + A[i]
Expand Down

0 comments on commit 7526574

Please sign in to comment.