Java Priority Queue Clean Code Solution
\nclass Solution {\n    public double maxAverageRatio(int[][] classes, int extraStudents) {\n        PriorityQueue<double[]> pq = new PriorityQueue<>(new Compar
```\nclass Solution {\n    public double maxAverageRatio(int[][] classes, int extraStudents) {\n        PriorityQueue<double[]> pq = new PriorityQueue<>(new Comparator<double[]>(){\n            public int compare(double[] a, double[] b){\n                double adiff = (a[0]+1)/(a[1]+1) - (a[0]/a[1]);                \n                double bdiff = (b[0]+1)/(b[1]+1) - (b[0]/b[1]);\n                if(adiff==bdiff) return 0;\n                return adiff>bdiff? -1:1;\n            }\n        });\n        \n        for(int[] c:classes) pq.add(new double[]{c[0],c[1]});\n        \n        for(int i =0;i<extraStudents;i++){\n            double[] curr = pq.poll();\n            pq.add(new double[]{curr[0]+1,curr[1]+1});\n        }\n        \n        double sum = 0;\n        while(!pq.isEmpty()){\n            double[] curr = pq.poll();\n            sum+=curr[0]/curr[1];\n        }\n        \n        return sum/classes.length;\n    }\n}\n```
['Heap (Priority Queue)', 'Java']