let kadane data =
let mutable maxV, max_currentPoint = 0, 0
for i in data do
max_currentPoint <- max 0 (max_currentPoint + i)
maxV <- max maxV max_currentPoint
maxV
kadane [-2; -3; 4; -1; -2; 1; 5; -3; ]
let mutable maxV, max_currentPoint = 0, 0
for i in data do
max_currentPoint <- max 0 (max_currentPoint + i)
maxV <- max maxV max_currentPoint
maxV
kadane [-2; -3; 4; -1; -2; 1; 5; -3; ]
No comments:
Post a Comment