Search
⌘K

Leetcode 396. Rotate Function

Given an array, maximize the rotation function F(k) = sum_{i=0}^{n-1} i * arr_k[i] over all k (rotating the array by k positions), with n up to 1e5. The core challenge is to avoid O(n^2) recomputation by using a mathematical recurrence to update F for each rotation in O(1), achieving an overall O(n) solution.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.