How to realize the problem of Survival number of golang leetcode browsing skills
This article mainly introduces the golang brush leetcode skills how to achieve the survival of the problem, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
Given the birth year and death year of N individuals, the birth year of the first person is birth [I] and the death year is death [I]. A method is implemented to calculate the year with the largest number of survivors.
You can assume that everyone was born between 1900 and 2000 (including 1900 and 2000). If a person is in a state of existence at any time of a year, then they should be included in the statistics of that year. For example, people who were born in 1908 and died in 1909 should be counted in 1908 and 1909.
If there are multiple years with the same number of survivors and all have the maximum value, output the smallest year.
Example:
Enter:
Birth = {1900, 1901, 1950}
Death = {1948, 1951, 2000}
Output: 1901
Tip:
0 < birth.length = = death.length