Download 10-week-algorithm-excercise-master/Week_06/53/maximum_subarray.go from Dorothydu/gitrepo_20: direct link, hf CLI and curl.
- Browser
- Download file 244 Bytes
-
https://huggingface.co/datasets/Dorothydu/gitrepo_20/resolve/main/10-week-algorithm-excercise-master/Week_06/53/maximum_subarray.go
- Command line
-
hf download hf://datasets/Dorothydu/gitrepo_20/10-week-algorithm-excercise-master/Week_06/53/maximum_subarray.go
-
curl -L -o maximum_subarray.go https://huggingface.co/datasets/Dorothydu/gitrepo_20/resolve/main/10-week-algorithm-excercise-master/Week_06/53/maximum_subarray.go
244 Bytes
| package main | |
| func maxSubArray(nums []int) int { | |
| cur := nums[0] | |
| res := cur | |
| for i := 1; i < len(nums); i++ { | |
| cur = max(cur, 0) + nums[i] | |
| res = max(res, cur) | |
| } | |
| return res | |
| } | |
| func max(x, y int) int { | |
| if x > y { | |
| return x | |
| } | |
| return y | |
| } | |