[Go] Delta arrays
Since we are rotating to the left, each number changes the total score twice:\n\n1. (-1) i == x-1 \n2. (+1) i == len(nums)-1\n\nWe can use this to determine, fo
Since we are rotating to the left, each number changes the total score twice:\n\n1. (-1) i == x-1 \n2. (+1) i == len(nums)-1\n\nWe can use this to determine, for each number, at what k\'s the total score would change.\n\nThen we iterate over the changes depending on k to find the maximum possible score.\n\nFinding the formula for number of left-rotations to reduce the value ( `((i+n)-(x-1))%n`) took a while with pen and paper.\nI don\'t expect that you find it intuitive.\n\n```go\nfunc bestRotation(nums []int) int {\n\tn := len(nums)\n\tdeltas := make([]int, n)\n\tvar score int\n\tfor i, x := range nums {\n\t\tdeltas[((i+n)-(x-1))%n]--\n\t\tdeltas[(i+1)%n]++\n\t\tif x <= i {\n\t\t\tscore++\n\t\t}\n\t}\n\tmaxScore := score\n\tvar maxIdx int\n\tfor k := 1; k < n; k++ {\n\t\tscore += deltas[k]\n\t\tif score > maxScore {\n\t\t\tmaxScore = score\n\t\t\tmaxIdx = k\n\t\t}\n\t}\n\treturn maxIdx\n}\n```
['Go']