Hindi Explanation with Comments | Prefix Sum
\n# Code\njava []\nclass Solution {\n    public int maximumPopulation(int[][] logs) {\n        int[] arr = new int[101];\n        for(int[] log : logs) {\n     
\n# Code\n```java []\nclass Solution {\n    public int maximumPopulation(int[][] logs) {\n        int[] arr = new int[101];\n        for(int[] log : logs) {\n            int birth = log[0];\n            int death = log[1];\n            arr[birth-1950]++;\n            arr[death-1950]--;\n        }\n\n        int max = arr[0];\n        int year = 1950;\n        for(int i = 1 ; i < 101; i++) {\n            arr[i] += arr[i-1];\n            if(arr[i] > max) {\n                max = arr[i];\n                year = 1950 + i;\n            }\n        }\n        return year;\n    }\n}\n```\n\n# Let\'s Understand\n\n    class Solution {\n        public int maximumPopulation(int[][] logs) {\n            // Step 1: Array initialize karte hain, size 101 hai kyunki 1950 se le kar 2050 tak ke saal cover karne hain\n            int[] arr = new int[101];\n            \n            // Step 2: Logs ko iterate karke population changes track karte hain\n            for (int[] log : logs) {\n                int birth = log[0];   // Birth year ko fetch karte hain\n                int death = log[1];   // Death year ko fetch karte hain\n                arr[birth - 1950]++;  // Birth year ke corresponding index ko increment karte hain\n                arr[death - 1950]--;  // Death year ke corresponding index ko decrement karte hain\n            }\n\n            // Step 3: Maximum population find karne ke liye initialization\n            int max = arr[0];  // 1950 ka population initial maximum population hai\n            int year = 1950;   // Initial year 1950 hai\n            // Year-by-year cumulative sum nikal kar maximum population find karte hain\n            for (int i = 1; i < 101; i++) {\n                arr[i] += arr[i - 1]; // Current year ki population calculate karte hain previous year ki population se\n                // Agar current year ka population maximum se zyada hai, to update karte hain maximum aur year\n                if (arr[i] > max) {\n                    max = arr[i];\n                    year = 1950 + i;\n                }\n            }\n\n            // Step 4: Maximum population wale year ko return karte hain\n            return year;\n        }\n    }\n
['Prefix Sum', 'Java']