Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function part2(invalid, arr::Vector{Int64})
- n = length(arr)
- low,high = n-1,n
- runsum = arr[low] + arr[high]
- while runsum != invalid
- if runsum < invalid
- low -= 1
- runsum += arr[low]
- else
- runsum -= arr[high]
- high -= 1
- end
- end
- sum(extrema(@view arr[low:high]))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement