Compute the average processing time for each machine from paired start and end logs.
You are given a list of process log records. Each record belongs to a machine and contains a process id, the machine id, a timestamp, and an event type indicating whether the process started or ended.
For every machine, consider all of its completed processes and compute the average processing time as:
Return the result for each machine, typically ordered by machine id.
A process duration is the difference between its end timestamp and start timestamp for the same process id on the same machine.
Example 1
Input
logs = [[1,1,5,"start"],[1,1,10,"end"],[2,1,12,"start"],[2,1,18,"end"],[3,2,7,"start"],[3,2,9,"end"]]
Output
[[1,6],[2,2]]
Explanation
Machine 1 has durations 5 and 6, so its average is 11 / 2 = 5.5. If the platform requires integer output, it may be represented according to the specific format. Machine 2 has one duration of 2.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.