DP O(n) precomputing
Intuition
Calculate score of first index i = 0
Calculate score change for each nums[i] -> store in dp

dp[k]++ if after k steps i->j and num[i] > i -> num[i] <=
# Intuition

- Calculate `score` of first index `i = 0`
- Calculate score change for each `nums[i]` `->` store in `dp`
    - `dp[k]++` if after `k` steps `i->j` and `num[i] > i` -> `num[i] <= j`
    - `dp[k]--` if after `k` steps `i->j` and `num[i] <= i` -> `num[i] > j`
- Set `dp[0] = score at 0`
- Loop and calculate max scores -> `bestRotation`

# Complexity
- Time complexity: O(n)
- Space complexity: O(n)

# Code
```golang []

func bestRotation(nums []int) int {
	dp := make([]int, len(nums))
	rs := 0
	mx := 0
	for i := 0; i < len(nums); i++ {
		if nums[i] <= i {
			mx++
		}
		if nums[i] > 0 && nums[i] < len(nums) {
			if nums[i] > i {
				dp[i+1] += 1
				k := i + len(nums) - nums[i] + 1
				if k < len(nums) {
					dp[k] -= 1
				}
			} else {
				dp[i-nums[i]+1] -= 1
				if i+1 < len(nums) {
					dp[i+1] += 1
				}
			}
		}
	}
	dp[0] = mx
	for i := 1; i < len(dp); i++ {
		dp[i] = dp[i-1] + dp[i]
		if dp[i] > mx {
			mx = dp[i]
			rs = i
		}
	}
	return rs
}
```
['Go']