matrix is a good way to understand this problem


  • 3
    D

    The function is a product of matrices ,like:
    F(k) = [k, k+1...n-2,n-1,0,....k-1] * A[n]
    F(k+1) = [k+1,k+2...n-1,0, 1,.....k] * A[n]
    so
    F(k+1) - F(k) = [1,1,1...-n+1,1,1,1] * A[n] = sum(A[n]) - n * A[n - 1 - k];


Log in to reply
 

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