← 返回 ibm 的题目列表Optimize Streaming Platform Sessions
类型:online_judge
An online streaming platform tracks user sessions. Each session has a specific start and end time, provided as a 2D array sessions, where sessions[i] = [start_i, end_i] represents the start and end time of the i-th session. Implement a function that determines the minimum number of recommendation engines required to process all sessions. Multiple sessions may be active at the same time, and recommendation engines can process multiple sessions. Return the minimum number of engines needed to ensure all sessions are managed.
Input:
sessions: A list consisting of [start, end], indicating session start and end times.
Output:
An integer denoting the minimum number of recommendation engines needed.
Example:
Input: sessions = [[1, 4], [2, 5], [7, 9]]
Output: 2
Explanation: There are 2 active sessions at times 2 and 3, so at least two recommendation engines are required.
Constraints:
1 <= sessions.length <= 10^5
0 <= start_i < end_i <= 10^9
Example
Input
1, 4
2, 5
7, 9