Python code for the problem


#1

def maxset(self, A):
s=[]
t=[]
for i in range(len(A)):
if(A[i]>=0):
s.append(A[i])
else:
t.append(s)
s=[]
t.append(s)
if(len(t)==0):
return A
else:
k=[0]*len(t)
for j in range(len(t)):
k[j]=sum(t[j])
q=max(k)
d=k.index(q)
return t[d]