We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e6261aa commit e521241Copy full SHA for e521241
Easy/Maximum Population Year.java
@@ -0,0 +1,15 @@
1
+class Solution {
2
+ public int maximumPopulation(int[][] logs) {
3
+ int[] population = new int[2051];
4
+ for (int[] log : logs) {
5
+ population[log[0]]++;
6
+ population[log[1]]--;
7
+ }
8
+ int maxPopulationYear = 0;
9
+ for (int i = 1950; i <= 2050; i++) {
10
+ population[i] += population[i - 1];
11
+ maxPopulationYear = population[i] > population[maxPopulationYear] ? i : maxPopulationYear;
12
13
+ return maxPopulationYear;
14
15
+}
0 commit comments