Created
April 1, 2020 04:51
-
-
Save wushbin/cce4a129fe5f3d8eb550e87eb5421310 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution { | |
| public int maxRotateFunction(int[] A) { | |
| int sum = 0; | |
| int F = 0; | |
| int len = A.length; | |
| for (int i = 0; i < len; i++) { | |
| sum += A[i]; | |
| F += i * A[i]; | |
| } | |
| int res = F; | |
| for (int i = 1; i < len; i++) { | |
| F = F + sum - len * A[len - i]; | |
| res = Math.max(res, F); | |
| } | |
| return res; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment