Well explained with help of comments || ✅✅beats 100%✅✅
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 minimumRightShifts(vector<int>& nums) {\n        int n = nums.size(); \n        int index = 0; \n\n        // Step 1: Find the point where the elements are in ascending order.\n        while (index + 1 < n && nums[index] < nums[index + 1])\n            index++;\n\n        // Step 2: If the entire array is already sorted, return 0.\n        if (index == n - 1)\n            return 0;\n\n        index++; // Move to the next index.\n        int curr_ind = index; // Store the index where ascending order breaks.\n\n        // Step 3: Check if the rest of the elements are also in ascending order.\n        while (index + 1 < n && nums[index] < nums[index + 1])\n            index++;\n\n        \n        if (index != n - 1) // If not all elements are in ascending order, return -1.\n            return -1;\n\n        if (nums[curr_ind] < nums[0] && nums[n - 1] < nums[0]) {\n            // If the element at curr_ind is less than the first element,\n            // and the last element is also less than the first element,\n            // it\'s possible to sort with right shifts.\n            // Calculate the number of right shifts needed.\n            return n - curr_ind;\n        }\n\n        // Step 5: If none of the conditions are met, return -1.\n        return -1;\n    }\n};\n\n```
['C++']