We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
deff(A,i,j):ifi==j:return0f=A[i]i,j=min(i,j),max(i,j)forainrange(i+1,j+1):if(f==1andA[a]==0)or(f==0andA[a]==1):f=1else:f=0returnfdefg(A,x,y):g=0foriinrange(x,y+1):forjinrange(i,y+1):g+=f(A,i,j)defchange(a,i):ifi==0:return[a]#code to change i number of element in adefmaximizingFunction(a,queries):List=[]forqueryinqueries:x=query[0]y=query[1]k=query[2]Max=0foriinrange(k+1):forAinchange(a,i):ifg(A,x,y)>Max:Max=g(A,x,y)returnMax
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Maximizing the Function
You are viewing a single comment's thread. Return to all comments →