mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-04 15:39:42 +08:00
Optimizing maxSum updation (#186)
* Optimizing maxSum updation compare maxSum with cummulativeSum only when cummulativeSum is greater than zero * Fixing linter error
This commit is contained in:

committed by
GitHub

parent
bc3d69dd12
commit
5ba1cffb20
@ -5,8 +5,7 @@ function KadaneAlgo (array) {
|
||||
cummulativeSum = cummulativeSum + array[i]
|
||||
if (cummulativeSum < 0) {
|
||||
cummulativeSum = 0
|
||||
}
|
||||
if (maxSum < cummulativeSum) {
|
||||
} else if (maxSum < cummulativeSum) {
|
||||
maxSum = cummulativeSum
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user