Answer the question
In order to leave comments, you need to log in
What algorithm should be used to find the maximum intersection of a set of segments?
There is a task:
The museum registers during the day the time of arrival and departure of each visitor. Thus, N pairs of values were obtained per day, where the first value in the pair shows the visitor's arrival time and the second value - the time of his departure. Find the period of time during which the maximum number of visitors were in the museum at the same time.
Is there a well-known algorithm for solving such problems?
Is the segment tree for the sum suitable for solving this problem?
Answer the question
In order to leave comments, you need to log in
@isxaker You yourself suggested a good option in my opinion
stackoverflow.com/questions/2244964/finding-number...
What is the question? :)
since precision is not required, create an array of 24 * 60 integers, and fill it with each segment, adding one to each element. then go through the resulting array, and find the maximum. O(n)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question