Minimum-right-shifts-to-sort-the-array (In java with example)
Explaination
Identify Pivot Points:
Loop through the array and check if nums[i-1] > nums[i].
If true, increment c and update ind to the index i.Check Edge Cases
**Explaination**
Identify Pivot Points:
Loop through the array and check if **nums[i-1] > nums[i]**.
If true, increment c and update ind to the index i.

Check Edge Cases:
- If c == 0, the array is already sorted, so return 0.
- If c > 1, there are multiple pivots, so sorting is not possible (return -1).
- If the first element **(nums[0])** is smaller than the last **(nums[nums.size() - 1]**), sorting is also not possible (return -1).

Calculate Shifts:
If exactly one pivot exists (c == 1), calculate the shifts required as:
shifts=size of nums−ind.

# Example 
Input: nums = [3, 4, 5, 1, 2]

Finding Pivot:
nums[0] < nums[1] → Continue.
nums[1] < nums[2] → Continue.
nums[2] > nums[3] → Pivot found at index 3, increment c to 1.

Checking Edge Cases:
c == 1 (only one pivot) → Pass.
nums[0] > nums[nums.size() - 1] (3 > 2) → Pass.
Calculate Shifts:
nums.size() - ind = 5 - 3 = 2.
**Output: 2.**

Input: nums = [1, 3, 5]
Finding Pivot:
No nums[i-1] > nums[i], so c = 0.
Checking Edge Cases:
c == 0 → Array is already sorted.
**Output:0.**


# Code
```java []
class Solution {
    public int minimumRightShifts(List<Integer> nums) {
        int ind =0,c=0;
        for(int i=1;i<nums.size();i++){
            if(nums.get(i-1)>nums.get(i)){
                ind = i;
                c++;
            }
        }
        if(c == 0){
            return 0;
        }
        if(c>1 || nums.get(0) < nums.get(nums.size()-1)){
            return -1;
        }
        return nums.size()-ind;
    }
}
```
['Java']