Given multiple array of array of elements T_n,
T_0 = [[0,2], [1,8], [5,9], [2,4], [7,8], [10,10]]
T_1 = [[7,10], [11,13], [20,25]]
where the first index of each element array indicates the start "time" and the second index the "end" time of each entity, for example [0,2] means start = 0, end = 2. (start and end time can be the same as well, in which case, its a "free" entity. Entity refers to an array in the array of arrays)
and a max "stay time"
M = 2
Example:
Given just one T,
T_0 = [[0,2], [1,8], [5,9], [2,4], [7,8], [10,10]]
M = 2
The max number of entities will be 4, since
I can "stay" from start = 0 to end = 2, so I will attain the entities [0,2], [1,8], [2,4], on top of the free entity [10,10]. Since there is only 1 T, the T_n that gives me the max entities will simply be T_0
Another Example
Given two Ts,
T_0 = [[0,2], [2,4]]
T_1 = [[7,10], [11,13], [20,25]]
M = 2
I can get 2 entities from T_0 by "staying" from start = 1 and end = 3.
I can also get 2 entities from T_1 by "staying from start = 9 and end = 11.
So, the max entities i can get is 2. And the T that will give me the max number of entities is both T_0 and T_1, since they give the same number of entities.
So the question is: How do I find an algorithm that gives me the maximum number of entities I can attain, and which T_n will give me this max number of entities?
I have tried something like a sliding window method, but I don't think it is the most efficient way, and was wondering if there is another way of doing it.