I came across an interview question:
"Given the lifetimes of different elephants. Find the period when the maximum number of elephants was alive." For instance:
Input: [5, 10] , [6, 15] , [2, 7]
Output: [6,7] (3 elephants)
I wonder if this problem could be related to the longest substring problem for the "n" number of rows, so that each row represents a continuous range of time period.
For example, for example: [5,10] <=> 5 6 7 8 9 10
If not, what could be a good solution to this problem? I want to encode it in C ++.
Any help would be appreciated.
Raj source share