Easy Solution || C++
Intuition\nSame as Rotate Array\n\n\n\n# Complexity\n- Time complexity:\n    O(NLog(N))\n\n\n# Code\n\nclass Solution {\npublic:\n   void helper(std::vector<int
# Intuition\nSame as [Rotate Array\n](https://link-url-here.org)\n\n\n# Complexity\n- Time complexity:\n    O(NLog(N))\n\n\n# Code\n```\nclass Solution {\npublic:\n   void helper(std::vector<int>& nums, int l, int h) {\n        while (l < h) {\n            std::swap(nums[l], nums[h]);\n            l++;\n            h--;\n        }\n    }\n\n    int minimumRightShifts(std::vector<int>& nums) {\n        int ind = -1;\n        std::vector<int> temp = nums;\n        std::sort(temp.begin(), temp.end()); // Sorting a copy of nums\n        helper(nums, 0, nums.size() - 1);    // Reversing the entire nums vector\n\n        // Finding the index where sorted portion ends\n        for (int i = 1; i < nums.size(); i++) {\n            if (nums[i] > nums[i - 1]) {\n                ind = i - 1;\n                break;\n            }\n        }\n\n        // Reversing two portions of nums\n        helper(nums, 0, ind);             // Reversing the portion from 0 to ind\n        helper(nums, ind + 1, nums.size() - 1); // Reversing the portion from ind+1 to end\n\n        if (temp != nums) {\n            return -1; // It\'s not possible to sort nums by right-shifting\n        }\n        return ind + 1; // Number of right shifts required for sorting nums\n    }\n};\n```
['C++']