[C++] 3 Lines, Beats 100%, Logic explained
\nclass Solution {\npublic:\n    vector<int> numMovesStones(int a, int b, int c) {\n        if(b<a) return numMovesStones(b,a,c);\n        if(c<b) return numMov
```\nclass Solution {\npublic:\n    vector<int> numMovesStones(int a, int b, int c) {\n        if(b<a) return numMovesStones(b,a,c);\n        if(c<b) return numMovesStones(a,c,b);\n        return {(b-a==2 || c-b==2) ? 1:(b-a!=1)+(c-b!=1), c-a-2};\n    }\n};\n```\nThe two if statements just ensure that a<b<c before the return statement.\n\nThe "minimum" case will always be 1 if the difference between x and y or y and z is equal to 2 (```b-a==2 || c-b==2```), since you can move the third variable between the other two in one move. \nOtherwise, the "minimum" case will always be a move for each endpoint (x or z) that needs to move next to the middle (y). \n```(b-a!=1)+(c-b!=1)``` gets this by adding one for each endpoint that needs to be moved, since in C/C++ bools automatically convert to 1 if true.\n\nThe "maximum" case is much simpler. You want to go step by step to reach the middle for each endpoint, so for the left side it would be y-x-1 and on the right side it would be z-y-1. Add these two movements by each endpoint and you get z-x-2, or ``` c-a-2```\n\nDrop any questions or comments you have below!
['C', 'C++']