Hi Nam H. Le,
I wanted to return 0 because there are no years overlapping. That was the original question. As for the modification of the problem statement, I am interested. What would be the problem statement. Let me know what you think 😃
First of all, to avoid ambiguation, we assume that if a person born (or die), he will born in the first (last) day of that year.
My solution is to create two 2-tuple for each person: (start_year, 1) and (end_year, -1).
And this one has O(nlogn) complexity. I'm wrong in previous coment.
Hi Nam H. Le,
I wanted to return 0 because there are no years overlapping. That was the original question. As for the modification of the problem statement, I am interested. What would be the problem statement. Let me know what you think 😃
First of all, to avoid ambiguation, we assume that if a person born (or die), he will born in the first (last) day of that year.
My solution is to create two
2-tuple
for each person:(start_year, 1)
and(end_year, -1)
.And this one has
O(nlogn)
complexity. I'm wrong in previous coment.Thanks Nam H. Le. That is an interesting variation of the problem