Easy Solution by Reversing
Intuition\n Describe your first thoughts on how to solve this problem. \nIt does so by iterating through all possible right shifts and checking if the vector be
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIt does so by iterating through all possible right shifts and checking if the vector becomes sorted after each shift\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n1. The function iterates through each element of the nums vector in the for loop, which has a time complexity of O(n), where n is the size of the vector.\n1. Inside the loop, it creates a copy of the vector and performs three reverse operations, each taking O(n) time.\n1. Additionally, it checks if the vector is sorted using is_sorted, which also takes O(n) time.\n1. Therefore, the overall time complexity of the function is O(n^2).\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n1. The function uses additional space to create a copy of the nums vector (vec). This copy has the same size as the original vector, so the space complexity for this part is O(n).\n1. Apart from that, no additional space is used.\n1. Therefore, the overall space complexity of the function is O(n).\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumRightShifts(vector<int>& nums) {\n        for(int i=0;i<nums.size();i++){\n            vector<int> vec=nums;\n            reverse(vec.begin(),vec.end());\n            reverse(vec.begin(),vec.begin()+i);\n            reverse(vec.begin()+i,vec.end());\n            if(is_sorted(vec.begin(),vec.end())) return i;\n        }\n        return -1;\n    }\n};\n\n// 3 4 5 1 2 \n// 2 1 5 4 3\n// 1 2 5 4 3\n// 1 2 3 4 5 \n```\n\nHappy Coding \uD83D\uDE0A\uD83D\uDE0A\n(\u25CF\'\u25E1\'\u25CF)(\u2741\xB4\u25E1`\u2741)(\u25CF\'\u25E1\'\u25CF)
['Array', 'C++']