Java || Easy
\n\t\tclass Solution {\n\t\t\tpublic int[] numMovesStonesII(int[] stones) {\n\t\t\t\tint n = stones.length;\n\t\t\t\t int[] ans = new int[2];\n\t\t\t\t int i = 
\n\t\tclass Solution {\n\t\t\tpublic int[] numMovesStonesII(int[] stones) {\n\t\t\t\tint n = stones.length;\n\t\t\t\t int[] ans = new int[2];\n\t\t\t\t int i = 0, j = 0, wsize, scount, minMoves = Integer.MAX_VALUE;\n\t\t\t\tArrays.sort(stones);\n\t\t\t\t while (j < n) {\n\t\t\t\t\twsize = stones[j] - stones[i] + 1;\n\t\t\t\t\tscount = j - i + 1;\n\n\t\t\t\t\tif (wsize > n) {\n\t\t\t\t\t\ti++;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (wsize == n - 1 && scount == n - 1)\n\t\t\t\t\t\tminMoves = Math.min(minMoves, 2);\n\n\t\t\t\t\telse minMoves = Math.min(minMoves, n - scount);\n\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t\tans[0] = minMoves;\n\t\t\t\tint maxMoves = 0;\n\t\t\t\t if (stones[1] == stones[0] + 1 || stones[n - 1] == stones[n - 2] + 1)\n\t\t\t\t\tmaxMoves = stones[n - 1] - stones[0] + 1 - n;\n\t\t\t\telse \n\t\t\t\t\tmaxMoves = Math.max(((stones[n - 1] - stones[1]) - (n - 1) + 1), ((stones[n - 2] - stones[0]) - (n - 1) + 1));\n\n\t\t\t\tans[1] = maxMoves;\n\t\t\t\treturn ans;\n\t\t\t}\n\t\t}
['Sliding Window', 'Java']