Python Solution For This


#1

class Solution:
# @param A : list of integers
# @return a list of integers
def maxset(self, A):
l=[]
j=0
for i in range(len(A)):
if(i==0):
l.append([])
if(A[i]>=0):
l[j].append(A[i])

        else:
            l.append([])
            j+=1
    p=[]
    m=0
    for i in l:
        sum1=sum(i)
        if(sum1>m):
            m=sum1
            p=i
        if(sum1==m):
            if(len(p)<len(i)):
                p=i
    return p