MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / maxSubArray2

Function maxSubArray2

maximum_subarray_53/solution.go:22–31  ·  view source on GitHub ↗

Solved for the 2nd time

(nums []int)

Source from the content-addressed store, hash-verified

20
21// Solved for the 2nd time
22func maxSubArray2(nums []int) int {
23 maxG := math.MinInt32
24 maxL := math.MinInt32
25 for i := 0; i < len(nums); i++ {
26 maxL = int(math.Max(float64(nums[i]), float64(maxL+nums[i])))
27 maxG = int(math.Max(float64(maxG), float64(maxL)))
28 }
29
30 return maxG
31}

Callers 1

Test_maxSubArrayFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_maxSubArrayFunction · 0.68