[Python][Sweep Line] Detailed explanation of Sweep Line algorithm
Decode the problemBeneath the contex of the problem, we are basically given a list of ranges on an axis and we are asked to find the smallest integer with the m
### Decode the problem
Beneath the contex of the problem, we are basically given a list of ranges on an axis and we are asked to find the smallest integer with the maximum number of overlapping ranges. This is a populate question pattern. One of the most famous problems is meeting room II: https://leetcode.com/problems/meeting-rooms-ii/

--- 

### Understand the alghorithm

So how do we approach this kind of problems? We use an alghorithm called [sweep line](https://en.wikipedia.org/wiki/Sweep_line_algorithm). It is more commonly used in computational geometry processing. But the idea holds same here: We are processing all the range edges in a sorted manner and track the state of our interest.

In the first for loop, we are iterating all the ranges given. And we use an `popluation` array to represent the axis. We are basically doing bucket sort here so all the starting and ending integers will be arranged in sorted order when we iterate it later. Additionally, we are also increment the count when we see starting integer and decrement count when we see ending integer. What we are really repesent here is how many ranges starts / ends at this given year, which is the state of our interest.

*Note in this problem, the range only exist between 1950 - 2050. And most ranges should be in contious fasion. So it makes a lot sense to just do bucket sort. In an open end range problem (imagine there is no limitation of years here) we will need to break up the start and end integers, group them and sort them, which usually requires O(nlogn) time complexity. Otherwise, we will waste a lot of idle meomories just for the bucket sort.*

Now in the second for loop, we are iterating the axis and update the current populations by adding/substracting the # of ranges starts/ends at all the given year. And we just need to keep track of the max Population we got.

##### Time complexity: O(n)

--- 

### Full Implementation
```
class Solution(object):
    def maximumPopulation(self, logs):
        """
        :type logs: List[List[int]]
        :rtype: int
        """
        totalYears = 2050 - 1950 + 1
        population = [0] * totalYears
        
        for log in logs:
            birthYear = log[0]
            deathYear = log[1]
            population[birthYear - 1950] += 1
            population[deathYear - 1950] -= 1
            
        currPop = maxPop = result = 0
        for year in range(totalYears):
            currPop += population[year]
            if currPop > maxPop:
                maxPop = currPop
                result = year
        
        return result + 1950
```        

['Python', 'Python3']