C++ ||  Beats 100% || O(N) Time
Time Complexity: O(N)\n\nclass Solution {\npublic:\n    int minimumRightShifts(vector<int>& nums) {\n        int n=nums.size();\n        int pi=-1;\n        // 
Time Complexity: O(N)\n```\nclass Solution {\npublic:\n    int minimumRightShifts(vector<int>& nums) {\n        int n=nums.size();\n        int pi=-1;\n        // find point from where the elements are not in non-decreasing order.\n        for(int i=1;i<n;i++){\n            if(nums[i]<nums[i-1]){\n                pi=i;\n                break;\n            }\n        }\n    \n        if(pi==-1) return 0; // if already sorted\n        \n        //Now check if the other half is also sorted or not and also check if the element there are smaller than nums[0], if not then return -1\n        for(int i=pi+1;i<n;i++){\n            if(nums[i]<nums[i-1] || nums[i]>nums[0]){\n                return -1;\n            }\n        }\n        return n-pi;\n    }\n};\n```
['C', 'C++']