min max array java
class Solution {\n    public int minMoves(int[] nums, int limit) {\n        \n        // minimum possible limit\n        int minV[] = new int[2limit+2];\n      
class Solution {\n    public int minMoves(int[] nums, int limit) {\n        \n        // minimum possible limit\n        int minV[] = new int[2*limit+2];\n        \n        // max possible limit\n        int maxV[] = new int[2*limit+2];\n        \n        // combination count\n        int comb[] = new int[2*limit+2 ];\n        int n = nums.length;\n        \n        for( int i=0;i<n/2;i++ ){\n            int a = Math.min( nums[i], nums[n-1-i] );\n            int b = Math.max( nums[i], nums[n-1-i] );\n            \n            int c = a+b;\n            \n            comb[c] = comb[c] + 1;\n            \n            minV[a+1] = minV[a+1] + 1;\n            maxV[ b+limit ] = maxV[ b+limit ] + 1;\n            \n            \n        }\n        \n        for( int i=1;i<minV.length;i++ ) {\n            minV[i] = minV[i] + minV[i-1];\n            maxV[i] = maxV[i] + maxV[i-1];\n        }\n        \n        int res = n;\n        \n        for( int i=2;i<minV.length;i++ ){\n            int val = comb[i];\n            \n            if( i<=limit ){\n                int t = n/2 - val + (minV[ minV.length - 1 ] - minV[i] );\n                res = Math.min(t,res);\n            } else{\n                int t = n/2 - val + ( maxV[i-1] );\n                res = Math.min(t,res);\n            }\n            \n        }\n        \n        return res;\n        \n        \n    }\n}
['Array']