Easiest explanation so far
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nFirst we translate this problem into the problem of maximum overlap of N 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nFirst we translate this problem into the problem of maximum overlap of N intervals\n\n        // overlap of N intervals:\n\n        // interval of values of k for nums[0] to have score\n        // interval of values of k for nums[1] to have score\n        // ...\n\n        // here, having score means after rotation its value is <= its index\n\n\n        // e.g. [2,3,1,4,0]\n        // interval for nums[0]: [1, 3]\n        // interval for nums[1]: [2, 3]\n        // interval for nums[2]: [3, 1] => [0, 1] + [3, 4]\n        // interval for nums[3]: [4, 4]\n        // interval for nums[4]: [0, 4]\n\nThen we get the maximum overlap by a simple algorithm like in https://leetcode.com/problems/check-if-all-the-integers-in-a-range-are-covered/description/\n\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(N)\n\n# Code\n```\nclass Solution {\npublic:\n    int bestRotation(vector<int>& nums) {\n        int N = nums.size();\n        vector<int> diff(N+1);\n        // overlap of N intervals:\n\n        // interval of values of k for nums[0] to have score\n        // interval of values of k for nums[1] to have score\n        // ...\n\n\n        // e.g. [2,3,1,4,0]\n        // interval for nums[0]: [1, 3]\n        // interval for nums[1]: [2, 3]\n        // interval for nums[2]: [3, 1] => [0, 1] + [3, 4]\n        // interval for nums[3]: [4, 4]\n        // interval for nums[4]: [0, 4]\n\n        // then we find max overlap of N intervals\n\n        for (int i = 0; i < N; i++) {\n            // move nums[i] to pos N-1: \n            int low = (i + 1) % N; \n\n            // move nums[i] to pos nums[i]\n            int high = (i - nums[i] + N) % N;\n            if (low <= high) {\n                // interval is [low, high]\n                diff[low]++;\n                diff[high + 1]--;\n            } else {\n                // interval is [0, high] + [low, N-1]\n                diff[0]++;\n                diff[high + 1]--;\n                diff[low]++;\n                diff[N]--;\n            }\n        }\n\n        for (int i = 1; i < N; i++) {\n            diff[i] += diff[i-1];\n        }\n        return max_element(diff.begin(), diff.end()) - diff.begin();\n    }\n};\n```
['C++']