JAVA Counting Sort Clean code soln
\'\'\'\npublic int[][] allCellsDistOrder(int R, int C, int r0, int c0) {\n         int [][]ans=new int[R*C][2];\n         int count[]=new int[R+C-1];\n        \
\'\'\'\npublic int[][] allCellsDistOrder(int R, int C, int r0, int c0) {\n         int [][]ans=new int[R*C][2];\n         int count[]=new int[R+C-1];\n        \n        for(int i=0;i<R;i++)\n        {\n            for(int j=0;j<C;j++)\n            {\n                int dis=Math.abs(r0-i) +Math.abs(c0-j);\n                count[dis]++;\n            }\n        }\n        \n        for(int i=1;i<count.length;i++) count[i]+=count[i-1];\n        \n           for(int i=0;i<R;i++)\n          {\n            for(int j=0;j<C;j++)\n            {\n                int dis=Math.abs(r0-i) +Math.abs(c0-j);\n                \n                if(dis==0)ans[0]=new int[]{i,j};\n                else{\n                    ans[count[dis-1]]=new int[]{i,j};\n                    count[dis-1]++;\n                }            \n            }\n          }\n     return ans;\n    }\n\'\'\'
[]