Clear Java 0ms implementation with comments
\nclass Solution {\n    public int maximumPopulation(int[][] logs) {\n        final int[] popChange = new int[2050-1950+1];\n        for (int i = 0; i < logs.le
```\nclass Solution {\n    public int maximumPopulation(int[][] logs) {\n        final int[] popChange = new int[2050-1950+1];\n        for (int i = 0; i < logs.length; i++) {\n            popChange[logs[i][0]-1950] += 1;\n            popChange[logs[i][1]-1950] -= 1;\n        }\n        \n        // Find the year that maximizes the sum of popChange from 0 to the year\n        // i.e. max_x(popChange[0..x])\n        int maxPop = -1;\n        int bestYear = -1;\n        int lastYearPop = 0;\n        for (int i = 0; i < popChange.length; i++) {\n            final int currentYearPop = lastYearPop + popChange[i];\n            if (currentYearPop > maxPop) {\n                maxPop = currentYearPop;\n                bestYear = 1950 + i;\n            }\n            lastYearPop = currentYearPop;\n        }\n        return bestYear;\n    }\n}\n```
[]