C++ Line Sweep O(N) 4 Lines (Using std::algorithm)
Let\'s use this as an input:\n    Input: logs = [[1993, 1995],[1994, 1996]]\n\tOutput: 1994\n\nIn the first line of code, I made an array of 101 elements initia
Let\'s use this as an input:\n    Input: logs = [[1993, 1995],[1994, 1996]]\n\tOutput: 1994\n\nIn the first line of code, I made an array of 101 elements initialized to 0 since the years are given as 1950 <= birth_i < death_i <= 2050 as given in the constraints.\n\nThe second line of code will increment the index of logs[x][0] - 1950 if we have a birth, and decrement the index of logs[x][1] - 1950 if we have a death.\n\nIn our example above, we would end up with a table like this:\n```\n0       ...    1       1       -1      -1      ...    0\n1950    ...    1993    1994    1995    1996    ...    2050\n```\n\nSince a single person was born in 1993 and 1994, we mark those years as 1. Since those people died in 1995 and 1996, we mark those years as -1.\n\nThe third line of code will get the prefix sum; also known as the [partial sum](https://www.cplusplus.com/reference/numeric/partial_sum/). Our table will look like this afterwards:\n```\n0       ...    1       2       1       0       ...    0\n1950    ...    1993    1994    1995    1996    ...    2050\n```\n\nBy doing this, we are able to see which year the maximum number of people were alive in.\n\nThe last line will find the [max element](https://www.cplusplus.com/reference/algorithm/max_element/) of the array (an iterator to the first maximum element will be returned), and it\'s distance from the beginning of the array will be found. In our example, max_element would point to index 44. The distance from the beginning (index 0) to index 44, is 44. We then add this to 1950 to get 1994, which is our solution.\n\n```\nclass Solution {\npublic:\n    int maximumPopulation(vector<vector<int>>& logs) {\n        vector<int> arr(101, 0);\n        for (int x = 0; x < logs.size(); arr[logs[x][0] - 1950]++, arr[logs[x][1] - 1950]--, x++);\n        partial_sum(arr.begin(), arr.end(), arr.begin());\n        return 1950 + distance(arr.begin(), max_element(arr.begin(), arr.end()));\n    }\n};\n```
[]