Find maximum product sub-array in a given array
Login/Signup to comment
3 comments on “Find maximum product sub-array in a given array”
×
30+ Companies are Hiring
Get Hiring Updates right in your inbox from PrepInsta
Login/Signup to comment
Get Hiring Updates right in your inbox from PrepInsta
x=[1, -2, -3,0,7, -8, -2]
y=[ ]
mul=1
for i in range(len(x)):
for j in range(i,len(x)):
mul=mul*x[j]
y.append(mul)
print(mul)
mul=1
print(“Maximum sub-array product is” , max(y))
arr=list(map(int,input().split()))
sum=1
for i in range(len(arr)):
if arr[i]==0:
pass
else:sum*=arr[i]
print(abs(sum))
list=[ 1, -2, -3, 0, 7, -8, -2 ,-2]
multi,max=1,0
for i in list:
multi*=i
if multi==0:
multi=1
if max<multi:
max=multi
print(max)