Python straightforward solution
class Solution:\n    def maximumPopulation(self, logs: List[List[int]]) -> int:\n        \n        d = {}\n        # use a dictionary to keep track of year:popu
class Solution:\n    def maximumPopulation(self, logs: List[List[int]]) -> int:\n        \n        d = {}\n        # use a dictionary to keep track of year:population size pair\n        for i in range(len(logs)):\n            for j in range(logs[i][0], logs[i][1]):\n                if j in d:\n                    d[j] += 1\n                else:\n                    d[j] = 1\n        # go over the dictionary to find out the earliest year with max population\n        max_pop = -1\n        max_pop_year = -1\n        #\n        for x in d:\n            if d[x] > max_pop:\n                max_pop = d[x]\n                max_pop_year = x\n            elif d[x] == max_pop:\n                if x < max_pop_year:\n                    max_pop_year = x\n        #\n        return(max_pop_year)
['Python', 'Python3']