Java Simple and easy solution, using max heap and faster than 100%, clean code with comments.
PLEASE UPVOTE IF YOU LIKE THIS SOLUTION\n\n\nclass Solution {\n    public double maxAverageRatio(int[][] classes, int extraStudents) {\n        //max heap\n    
**PLEASE UPVOTE IF YOU LIKE THIS SOLUTION**\n\n```\nclass Solution {\n    public double maxAverageRatio(int[][] classes, int extraStudents) {\n        //max heap\n        //here we are using Max Heap, whaich has maximum element in root\n        PriorityQueue<Class> maxHeap = new PriorityQueue<Class>(Comparator.comparingDouble(o -> -o.gainPassRatio));\n        \n        \n        for(int[] eachClass : classes){\n            int pass = eachClass[0];\n            int total = eachClass[1];\n            \n            maxHeap.add(new Class(pass, total,  getGainPassRatio(pass, total)));\n        }\n        \n        \n        while(extraStudents --> 0){\n            //we are using Gready Approach \n            //get the class, which will have a maximum \n            //gain in passing ratio, if we add a student\n            Class c =  maxHeap.remove();\n            \n            //this class will have maximum gain in passing ratio\n            //so add 1 extra student (who always pass)\n            c.pass = c.pass + 1;\n            c.total = c.total + 1;\n            c.gainPassRatio = getGainPassRatio(c.pass + 1, c.total + 1);\n            \n            maxHeap.add(c);\n        }\n        \n        double passRatioSum = 0.0d;\n        while(!maxHeap.isEmpty()){\n            Class c =  maxHeap.remove();\n            passRatioSum += ((double)c.pass / c.total);\n        }\n        \n        \n        return passRatioSum / classes.length;\n    }\n    \n    private double getGainPassRatio(int pass, int total){\n        double passRatio =  (double)pass / total;\n        \n        //add 1 student, \n        pass++;\n        total++;\n        \n        double passRatioAfterAdding = (double)pass / total;\n        \n        //find gain in passing ratio, if we add 1 student\n        return passRatioAfterAdding - passRatio; \n    }\n}\n\nclass Class {\n    int pass;\n    int total;\n    double gainPassRatio;\n    \n    public Class(int pass, int total, double gainPassRatio){\n        this.pass = pass;\n        this.total = total;\n        this.gainPassRatio = gainPassRatio;\n    }\n}\n```
['Heap (Priority Queue)']