Golang O(n) solution, beat 100%
go\nfunc bestRotation(nums []int) int {\n\t// 0 \u2264 step < nums.length\n\tstep, best := 0, math.MinInt32\n\tbounds := make([][]int, len(nums))\n\t// value \u
```go\nfunc bestRotation(nums []int) int {\n\t// 0 \u2264 step < nums.length\n\tstep, best := 0, math.MinInt32\n\tbounds := make([][]int, len(nums))\n\t// value \u2264 index, get points\n\t// step to left\n\tfor i, v := range nums {\n\t\tif v <= i {\n\t\t\tbounds[i] = append(bounds[i], 0)\n\t\t\tbounds[i] = append(bounds[i], i-v)\n\t\t}\n\t\tif i+1 <= len(nums)-1 {\n\t\t\tbounds[i] = append(bounds[i], i+1)\n\t\t\tbounds[i] = append(bounds[i], min(i+len(nums)-v, len(nums)-1))\n\t\t}\n\t}\n\tmagic := make([]int, len(nums))\n\tfor _, bound := range bounds {\n\t\tfor i, v := range bound {\n\t\t\tif i % 2 == 0 {\n\t\t\t\tmagic[v]++\n\t\t\t} else {\n\t\t\t\tmagic[(v+1)%len(nums)]--\n\t\t\t}\n\t\t}\n\t}\n\tcurr := 0\n\tfor i, v := range magic {\n\t\tcurr += v\n\t\tif curr > best {\n\t\t\tstep = i\n\t\t\tbest = curr\n\t\t}\n\t}\n\treturn step\n}\n\nfunc min(values ...int) int {\n\tminValue := math.MaxInt64\n\tfor _, v := range values {\n\t\tif v < minValue {\n\t\t\tminValue = v\n\t\t}\n\t}\n\treturn minValue\n}\n```
['Go']