Simple if you know all test cases | Beats 100%
\n\n# Approach\nTypes of test case you can get.\na) 1... _ 10 _... 20\nb) 1 _ _ 4 _ _ 7\nc) 1 _ 3 _ _ 6\nd) 1 2 _ _ 5 \ne) 1 _ 2 _ 3\nf) 1 2 _ 4\ng) 1 2 3\n\nx,
\n\n# Approach\nTypes of test case you can get.\na) 1... _ 10 _... 20\nb) 1 _ _ 4 _ _ 7\nc) 1 _ 3 _ _ 6\nd) 1 2 _ _ 5 \ne) 1 _ 2 _ 3\nf) 1 2 _ 4\ng) 1 2 3\n\nx,y,z be the numbers in ascending order.\n* if you find **y-x==1 && z-y==1** (i.e. case g) then you don\'t have to shift stone for min and max and ans will be {0,0}.\n* Now max can be either 2 or less than two. See all possible types written above.\n* So to get max simply do **(y-x)+(z-y)-2**. -2 because you have to keep difference of 1 from x to y and y to z (consecutive no.).\n* To get min, for type a and b  **z-y >2 && y-x > 2** you can directly say min is *2*\n*  To get min, for remaining types c,d,e,f ans is *1*\n\n# Code\n```\nclass Solution {\n    public int[] numMovesStones(int a, int b, int c) {\n        int x=0,y=0,z=0;\n        z=Math.max(Math.max(a,b),c);\n        x=Math.min(Math.min(a,b),c);\n        y=a+b+c-(z+x);\n        int max=0,min=0;\n        max=(y-x)+(z-y)-2;\n        min=(x+1)==y &&(y+1)==z ? 0:\n               ((z-y) > 2 && (y-x) > 2 ) ? 2:1;\nint [] arr={min,max};\nreturn arr;\n    }\n}\n```\n![4fl3zu.jpg](https://assets.leetcode.com/users/images/ab3941f1-1eb8-4e6b-b452-f59caa027460_1687414721.3325694.jpeg)\n
['Java']