Cpp heap solution
I realised that every element had an "expirary date" relative to where we defined k. For example, [0,0,0,1] - the element 1 has an expirary date of 3 - 1 = 2(0 
I realised that every element had an "expirary date" relative to where we defined k. For example, [0,0,0,1] - the element 1 has an expirary date of 3 - 1 = 2(0 indexed), because it will no longer provide a point when we rotate by 3 elements. Utilizing this logic, we can create a second pointer to define a second expirary date.\n```\nclass Solution {\npublic:\n    int bestRotation(vector<int>& nums) {\n        int k = nums.size() - 1;\n        int res = 0;\n        int maxC = 0;\n        \n        priority_queue<int,vector<int>,greater<>> f;\n        priority_queue<int> s;\n        \n        for(int i = 0;i<nums.size();i++){\n            while(f.size() && f.top() <= -1)\n                f.pop();\n            f.push(i-nums[i]);\n        }\n        maxC = f.size();\n        for(int i = 0;i<nums.size();i++){\n            \n            while(f.size() && f.top() <= i)\n                f.pop();\n            s.push((k--) - (nums.size() - nums[i]));\n            while(s.size() && s.top() > k)\n                s.pop();\n            \n            if(maxC < f.size() + s.size()){\n                maxC = f.size() + s.size();\n                res = i+1;\n            }\n        }\n        return res;\n    }\n};\n```
['Heap (Priority Queue)', 'C++']