Java find correct position in sorted array
\npublic int minimumRightShifts(List<Integer> nums) {\n        int[] arr = new int[nums.size()];\n        int index = 0;\n        for (int num : nums) arr[index
```\npublic int minimumRightShifts(List<Integer> nums) {\n        int[] arr = new int[nums.size()];\n        int index = 0;\n        for (int num : nums) arr[index++] = num;\n        Collections.sort(nums);\n        int left = -1, right = nums.size();\n        int pos = -1;\n        while (right - left > 1) {\n            int mid = left + (right - left) / 2;\n            if (nums.get(mid) == arr[0]) {\n                pos = mid;\n                break;\n            } else if (nums.get(mid) < arr[0]) left = mid;\n            else right = mid;\n        }\n        for (int i = 1; i < arr.length; i++) {\n            if (!nums.get((i + pos) % arr.length).equals(arr[i])) return -1;\n        }\n        return pos;\n    }\n```
['Sorting', 'Java']