Minimum Right Shifts to sort the array - java code
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int minimumRightShifts(List<Integer> nums) {

        List<Integer> sortedNums = new ArrayList<>(nums);
        Collections.sort(sortedNums);

        if (nums.equals(sortedNums)) return 0;
        int mini = Collections.min(nums);
        int ind = -1;

        for (int i = 0; i < nums.size(); i++)
        {
            if (nums.get(i) == mini){
                ind = i;
                break;
            }
        }

        int rotations = 0;
        if(ind != -1) rotations = (nums.size() - ind);
        
        int points = 0;
        if (nums.get(0) < nums.get(nums.size() - 1)) points++;

        for (int i = 1; i < nums.size(); i++)
        {
            if (nums.get(i) < nums.get(i - 1)) points++;
        }
        return (points > 1) ? -1: rotations;
    }

}
```
['Java']