Problem · Array
Common Camera Motion Intervals
Learn this problemProblem statement
Each camera provides strictly increasing integer timestamps and a motion intensity for every timestamp. For one camera, a motion period is a maximal consecutive run of samples whose intensity is at least threshold; its inclusive interval runs from the first qualifying timestamp through the last.
Return the sorted inclusive intervals during which every camera is simultaneously in one of its motion periods.
Function
commonMotionIntervals(timestamps: int[][], intensities: double[][], threshold: double) → int[][]Examples
Example 1
timestamps = [[1,2,3,4,5]]intensities = [[0.1,0.7,0.8,0.2,0.9]]threshold = 0.6return = [[2,3],[5,5]]The qualifying samples form two maximal runs.
Example 2
timestamps = [[1,2,3,4,5],[0,2,3,5,6]]intensities = [[0.8,0.8,0.2,0.9,0.9],[0.1,0.7,0.7,0.7,0.2]]threshold = 0.7return = [[2,2],[4,5]]Intersecting [1,2] and [4,5] with the second camera's [2,5] gives two common periods.
Constraints
1 <= timestamps.length == intensities.length <= 1001 <= timestamps[c].length == intensities[c].length- The total sample count is at most
200000. - Each timestamp row is strictly increasing and values fit in signed 32-bit integers.
0.0 <= intensities[c][i], threshold <= 1.0