Maximum Subarray Sum

Find the maximum sum of a contiguous subarray using Kadane's algorithm.

Code

Algorithms
echo "$arr" | jq 'reduce .[] as $x ({max: .[0], cur: .[0]}; .cur = [($x), (.cur + $x)] | max | .max = [.max, .cur] | max) | .max'

Parameters

Array of numbers (JSON)

Server

More Bash Snippets