Simple approach - get min, rotate the array and check if it sort | O(N)
Complexity\n- Time complexity: O(N)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(N)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int minimumRightShifts(List<Integer> nums) {\n        int[] ans = new int[nums.size()];\n        int min = 0;\n        \n        for(int i = 0; i < nums.size(); i++){\n            if(i > 0 && nums.get(min) > nums.get(i))   min = i;\n        }\n        \n        for(int i = 0; i < nums.size(); i++)    ans[(i + nums.size() - min) % nums.size()] = nums.get(i);\n        \n        for(int i = 0; i < ans.length - 1; i++)    if(ans[i] > ans[i + 1]) return -1;\n        \n        return min == 0 ? min : nums.size() - min;\n    }\n}\n```
['Java']