Python solution


  • 0
    A
    def maxRotateFunction(self, A):
        currentvalue = 0
        maxvalue = 0
        n = len(A)
        sumOfA = sum(A)
        for i in range(n):
            currentvalue += i*A[i]
        maxvalue = currentvalue
        for i in range(n):
            currentvalue += sumOfA - A[n-i-1]*n
            maxvalue = max(maxvalue,currentvalue)
        return maxvalue

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.