Company: Amazon_29july
Difficulty: medium
Process Performance Queries Problem Description You are a developer at Amazon evaluating the performance of processing units. There are n processes, where each process i runs from starts[i] to ends[i] (both inclusive). You are given q queries, each defined by three arrays: query_process[j] -> the exact number of processes to check, query_start[j] -> the start time of the query interval, query_end[j] -> the end time of the query interval. For each query j , determine how many seconds within [query_start[j], query_end[j]] (inclusive) have exactly query_process[j] processes running. Return an array of size q with the result for each query. Examples Example 1: Suppose n = 3 , starts = [0, 1, 2] , ends = [2, 5, 10] , q = 2 , query_process = [1, 2] , query_start = [1, 4] , query_end = [10, 8] . Time | Process Status | In Execution -----|----------------|-------------- 0 | process 0 starts | [0] 1 | process 1 starts | [0, 1] 2 | process 2 starts | [0, 1, 2] 3 | process 0 ends | [1, 2] 4 | - |