c++ prefix array solution O(n)
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```\nclass Solution {\npublic:\n    int bestRotation(vector<int>& nums) {\n        /*\n        BRUTE FORCE TLE o(N^2)->10^(5*2)\n        int maxi=INT_MIN;\n        int ans=-1;\n        int n=nums.size();\n        for(int k=0;k<n;k++){\n            int res=0;\n            for(int i=0;i<n;i++){\n                int ind=(i+n-k)%n;\n                if(nums[i]<=ind){\n                    res++;\n                }\n            }\n            if(res>maxi){\n                maxi=res;\n                ans=k;\n            }\n        }\n        return ans;\n        */\n        int n=nums.size();\n        vector<int> arr(n+2,0);\n        for(int i=0;i<n;i++){\n            int r_maxi=i+n-max(nums[i],i+1);\n            int r_mini=i+1;\n            arr[r_mini]++;\n            arr[r_maxi+1]--;\n            if(nums[i]<=i){\n                int l_mini=0;\n                int l_maxi=i-nums[i];\n                arr[l_mini]++;\n                arr[l_maxi+1]--;\n            }\n        }\n        int maxi=arr[0];\n        int ans=0;\n        for(int i=1;i<n;i++){\n            arr[i]+=arr[i-1];\n            if(maxi<arr[i]){\n                maxi=arr[i];\n                ans=i;\n            }\n        }\n\n        return ans;\n    }\n};\n```
['C++']