You are viewing a single comment's thread. Return to all comments →
Can anybody Suggest what is the mistake in my code I belive the logic is correct :
def subarray(A): start = next(x for x, val in enumerate(A) if val > 0) end = next(n-x for x, val in enumerate(A[n:0:-1]) if val > 0 ) largestValue(Arr=A[start:end]) def largestValue(Arr): Sum=sum(Arr) result=0 #print(Arr,l) for i in range(len(Arr)-1): Sum-=Arr[i] result+=Arr[i] * (Sum) print(result) n = int(input()) A = list(map(int, input().rstrip().split())) subarray(A)
Seems like cookies are disabled on this browser, please enable them to open this website
Pair Sums
You are viewing a single comment's thread. Return to all comments →
Can anybody Suggest what is the mistake in my code I belive the logic is correct :