pop and unshift strategy
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:\nO(n^2) because there is a check in the loop for every iteration\n\n- Space complexity:\nO(n)\n\n# Code\n```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar minimumRightShifts = function(nums) {\n    let output = 0;\n    let sorted = [...nums].sort((a, b) => a - b); // Create a sorted copy of nums\n    \n    if (JSON.stringify(nums) === JSON.stringify(sorted)) {\n        return output; // If already sorted, return 0\n    }\n    \n    for (let i = 0; i < nums.length; i++) {\n        let last = nums.pop(); // remove the last element\n        nums.unshift(last); // add the last element at the beginning\n        output++;\n        \n        if (JSON.stringify(nums) === JSON.stringify(sorted)) {\n            return output;\n        }\n    }\n    \n    return -1; // If no sorting is achieved after full rotation\n};\n\n```
['JavaScript']