We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 758b61d + 8a6d3b5 commit a573f11Copy full SHA for a573f11
ClassicalAlgos/kadane's_algorithm/Kadane's_Algorithm.py
@@ -0,0 +1,15 @@
1
+T = int(input())
2
+for _ in range(T):
3
+ n = int(input())
4
+ a = list(map(int, input().split()))
5
+ maxglobal = -9999999999999999999
6
+ max_here = 0
7
+
8
+ for i in range(0, n):
9
+ max_here = max_here + a[i]
10
+ if (maxglobal < max_here):
11
+ maxglobal = max_here
12
13
+ if max_here < 0:
14
15
+ print(maxglobal)
ClassicalAlgos/kadane's_algorithm/readme.md
@@ -0,0 +1,3 @@
+ ## Kadane's algorithm
+ Used to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.
0 commit comments