Simple O(n) Python Solution


#1
class Solution:
# @param A : list of integers
# @return a list of integers
def maxset(self, A):
    accum = []
    max_vec = []
    res = []
    for ndx, el in enumerate(A):
        if el >= 0:
            accum.append(el)
            
        if el < 0 or (ndx == len(A) - 1):
            if accum:
                pot_vec = [sum(accum), len(accum)]
                if pot_vec > max_vec:
                    max_vec = pot_vec
                    res = accum

            accum = []
            
    return res