Sort by

recency

|

11 Discussions

|

  • + 0 comments

    Here is Maximizing the function problem solution in Python Java C++ and c programming - https://programs.programmingoneonone.com/2021/07/hackerrank-maximizing-the-function-problem-solution.html

  • + 0 comments

    i am not able to underdstand the question ? can anyone help me out

  • + 0 comments
    def f(A,i,j):
        if i==j:
            return 0
        f = A[i]
        i,j = min(i,j),max(i,j)
        for a in range(i+1,j+1):
            if (f==1 and A[a]==0) or (f==0 and A[a]==1):
                f = 1
            else:
                f = 0
        return f
     
    def g(A,x,y):
        g = 0
        for i in range(x,y+1):
            for j in range(i,y+1):
                g += f(A,i,j)
    
    def change(a,i):
        if i==0:
            return [a]
        #code to change i number of element in a
    
    def maximizingFunction(a, queries):
        List = []
        for query in queries:
            x = query[0]
            y = query[1]
            k = query[2]
            Max = 0
            for i in range(k+1):
                for A in change(a,i):
                    if g(A,x,y)>Max:
                        Max = g(A,x,y)
        return Max
    
  • + 0 comments

    The queries array contains the values on which the operation is to be done in 0th index?

  • + 0 comments

    need sugesstions