Download benchmarks/quixbugs/python/max_sublist_sum.py from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 517 Bytes
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/quixbugs/python/max_sublist_sum.py
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/benchmarks/quixbugs/python/max_sublist_sum.py
-
curl -L -o max_sublist_sum.py https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/quixbugs/python/max_sublist_sum.py
517 Bytes
| def max_sublist_sum(arr): | |
| max_ending_here = 0 | |
| max_so_far = 0 | |
| for x in arr: | |
| max_ending_here = max(0, max_ending_here + x) | |
| max_so_far = max(max_so_far, max_ending_here) | |
| return max_so_far | |
| """ | |
| Max Sublist Sum | |
| max-sublist-sum | |
| Efficient equivalent to max(sum(arr[i:j]) for 0 <= i <= j <= len(arr)) | |
| Algorithm source: WordAligned.org by Thomas Guest | |
| Input: | |
| arr: A list of ints | |
| Output: | |
| The maximum sublist sum | |
| Example: | |
| >>> max_sublist_sum([4, -5, 2, 1, -1, 3]) | |
| 5 | |
| """ | |