TS solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nfunction bestRotation(nums: number[]): number {\n    const n = nums.length;\n    const bad = new Array(n).fill(0);\n    for (let i = 0; i < n; ++i) {\n        const left = (i - nums[i] + 1 + n) % n;\n        const right = (i + 1) % n;\n        bad[left]--;\n        bad[right]++;\n        if (left > right) {\n            bad[0]--;\n        }\n    }\n\n    let best = -n;\n    let ans = 0, cur = 0;\n    for (let i = 0; i < n; ++i) {\n        cur += bad[i];\n        if (cur > best) {\n            best = cur;\n            ans = i;\n        }\n    }\n    return ans;\n}\n```
['TypeScript']