forked from Google-DSC-TMSL/ProjectAlgorithms
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKadaneAlgo.py
More file actions
Latest commit
35 lines (25 loc) · 759 Bytes
/
Copy pathKadaneAlgo.py
File metadata and controls
35 lines (25 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
importmath
classSolution:
defmaxSubArraySum(self,arr,N):
##Your code here
max_ending=0
max_so_far=-math.inf
foriinrange(N):
max_ending+=arr[i]
ifmax_so_far<max_ending:
max_so_far=max_ending
ifmax_ending<0:
max_ending=0
returnmax_so_far
importmath
# Aditya Seth
defmain():
T=int(input())
while(T>0):
n=int(input())
arr=[int(x) forxininput().strip().split()]
ob=Solution()
print(ob.maxSubArraySum(arr,n))
T-=1
if__name__=="__main__":
main()