1983. Maximum Population Year
My accepted Python solution to LeetCode problem 1983, Maximum Population Year, running in 3ms.
- Difficulty: Easy
- Python
- Runtime 3ms
- Memory 17.2MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 3ms, memory 17.2MB, accepted 2025-12-30.
class Solution:
def maximumPopulation(self, logs: List[List[int]]) -> int:
# Use difference array approach
years = [0] * 101 # 1950 to 2050
for birth, death in logs:
years[birth - 1950] += 1
years[death - 1950] -= 1
max_pop = 0
current_pop = 0
result = 1950
for i in range(101):
current_pop += years[i]
if current_pop > max_pop:
max_pop = current_pop
result = 1950 + i
return result