Average Process Time from CSV
Problem statement
Each CSV row has the form id,start,end, where start and end are integer timestamps and end >= start. Group rows by id and return each ID's average process duration end - start.
Return rows [id, average] sorted lexicographically by ID. The input guarantees every average is an integer.
Function
averageProcessTimes(rows: String[]) → String[][]Examples
Example 1
rows = ["a,10,20","b,0,4","a,30,50"]return = [["a","15"],["b","4"]]ID a has durations 10 and 20, whose average is 15.
Constraints
1 <= rows.length <= 100000.- IDs are nonempty ASCII strings without commas.
0 <= start <= end <= 10^9.- Each per-ID duration sum is divisible by its row count.