[Java] simple+clean sliding window
\nclass Solution {\n    public int[] numMovesStonesII(int[] A) {\n        Arrays.sort(A);\n        int N=A.length;\n        if(A[N-1]-A[0]+1==A.length)return ne
```\nclass Solution {\n    public int[] numMovesStonesII(int[] A) {\n        Arrays.sort(A);\n        int N=A.length;\n        if(A[N-1]-A[0]+1==A.length)return new int[]{0,0};\n        \n        int max=1+Math.max(A[N-1]-A[1]+1-N,A[N-2]-A[0]+1-N);   \n        int min=Integer.MAX_VALUE;\n       \n        \n        Queue<Integer>q=new LinkedList<>();\n        q.add(A[0]);\n        for(int i=1;i<A.length;i++){\n            if(A[i]-q.peek()+1>=N){\n                if(A[i]-q.peek()+1==N){\n                    min=Math.min(min,N-q.size()-1);\n                }else{\n                    if(A[i]-q.peek()==N)min=1;\n                    else{\n                        int M=Math.max(2,N-q.size());\n                        min=Math.min(min,M);\n                    }\n                }\n                \n                q.poll();\n            }\n            q.add(A[i]);\n        }\n        \n        return new int[]{min,max};\n    }\n    \n}\n```
[]