<commit_before>"""
    Difficulty: ***
    Code:       **
    Ref: https://www.hackerrank.com/challenges/maxsubarray
"""
import unittest


def max_subarray(arr):
    largest_val = float('-inf')
    non_contiguous = 0
    contiguous = 0
    cur = 0
    for num in arr:
        if num > largest_val:
            largest_val = num
        if num > 0:
            non_contiguous += num
        if num + cur < 0:
            cur = 0
            continue
        cur += num
        if cur > contiguous:
            contiguous = cur
    if largest_val < 0:
        return largest_val, largest_val
    return contiguous, non_contiguous

<commit_msg>Docs: Added problem category<commit_after>"""
    Difficulty: ***
    Code:       **
    Required Knowledge: Dynamic Programming
    Ref: https://www.hackerrank.com/challenges/maxsubarray
"""
import unittest


def max_subarray(arr):
    largest_val = float('-inf')
    non_contiguous = 0
    contiguous = 0
    cur = 0
    for num in arr:
        if num > largest_val:
            largest_val = num
        if num > 0:
            non_contiguous += num
        if num + cur < 0:
            cur = 0
            continue
        cur += num
        if cur > contiguous:
            contiguous = cur
    if largest_val < 0:
        return largest_val, largest_val
    return contiguous, non_contiguous


{'fraction_non_alphanumeric': 0.08650260999254288, 'fraction_numerical': 0.010439970171513796, 'mean_word_length': 1.7727272727272727, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7217813', 'n_tokens_mistral': 439, 'n_tokens_neox': 405, 'n_words': 115}