Maximum subarray problem: Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
Add: bibcode, doi-access, isbn. | Use this bot. Report bugs. | Suggested by Headbomb | Linked from Wikipedia:WikiProject_Academic_Journals/Journals_cited_by_Wikipedia/Sandbox2 | #UCB_webform_linked 822/1051
m No empty subarrays admitted: Corrected Python code to correctly represent negative infinity
Line 58:
def max_subarray(numbers):
"""Find the largest sum of any contiguous subarray."""
best_sum = float('- infinityinf')
current_sum = 0
for x in numbers: