Easy Edgecases || Java || C++
Intuition
Intuition can be formed with the following hint
For the minimum: We can always do it in at most 2 moves, by moving one stone next to another, then the
# Intuition
- Intuition can be formed with the following hint 
- For the minimum: We can always do it in at most 2 moves, by moving one stone next to another, then the third stone next to the other two. When can we do it in 1 move? 0 moves? For the maximum: Every move, the maximum position minus the minimum position must decrease by at least 1.
- Check the cases.

# Approach
- If a,b,c are consecutive no need to move the stones. It implies `min=0` and `max=0`
- If not consecutive,minimum moves would be either 1 or 2 
- If eiter of the pair has a gap less than or equal to 2 the other stone can be moved in between them. It implies `min=1` else `min=2`.
- If not consecutive, `max` can be the difference between 1st stone and last stone -1 (stone cannot be placed on the existing stone)
<!-- Describe your approach to solving the problem. -->

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

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

# Code
```cpp []
class Solution {
public:
    vector<int> numMovesStones(int a, int b, int c) {
        vector<int>arr={a,b,c};
        sort(begin(arr),end(arr));
        int mini=0;
        int maxi=0;
        if(arr[2]-arr[0]==2){
            return {0,0};
        }
        if(min(arr[1]-arr[0],arr[2]-arr[1])<=2){
            mini=1;
        }
        else{
            mini=2;
        }
        maxi=arr[2]-arr[0]-2;
        return {mini,maxi};
    }
};
```
```Java []
class Solution {
    public int[] numMovesStones(int a, int b, int c) {
        int [] arr = new int[3];
        arr[0]=a;
        arr[1]=b;
        arr[2]=c;
        Arrays.sort(arr);
        int min=0;
        int max=0;
        if(arr[2]-arr[0]==2){
            return new int[]{0,0};
        }
        if(Math.min(arr[1]-arr[0],arr[2]-arr[1])<=2){
            min=1;
        }
        else{
            min=2;
        }
        max=arr[2]-arr[0]-2;
        return new int[]{min,max};
    }
}
```
['Math', 'Brainteaser', 'C++', 'Java']