FastPrepFind Shared Camera Activity Periods
Problems/Find Shared Camera Activity Periods

Find Shared Camera Activity Periods

Serval logoServal● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Serval phone screen. The report defines the activity periods that pass a threshold on each camera, and where the periods of several cameras overlap. It does not say how to handle one camera alone, empty input, periods that only touch, or the size limits. Our version is about 96% the same as the reported question.

You are given timestamp-sorted intensity readings for one or more cameras. For camera c, timestamps[c][i] and intensities[c][i] describe reading i. A reading is active when its intensity is at least threshold.

Within one camera, a maximal consecutive run of active readings forms a closed period from the first reading's timestamp through the last reading's timestamp. An inactive reading ends the current run.

Return the maximal closed time periods during which every camera is active. Compute each camera's periods and intersect them. For this exercise, assume a one-reading run is [timestamp,timestamp]. A camera with no active period makes the result empty. Merge final closed fragments that overlap or touch at one endpoint.

Function

findSharedActivityPeriods(timestamps: int[][], intensities: double[][], threshold: double) → List<List<Integer>>

Examples

Example 1

timestamps = [[1,5,11,15,17,20,27,31,36]]intensities = [[0.4,0.2,0.9,0.9,0.8,0.3,0.9,1.0,0.8]]threshold = 0.8return = [[11,17],[27,36]]

The readings at timestamps 11, 15, 17 are consecutive and active, then timestamp 20 ends that run. The readings at 27, 31, 36 form the second run. Values equal to the threshold qualify.

Example 2

timestamps = [[1,4,7,10,13],[2,4,6,11,13]]intensities = [[0.9,0.9,0.2,0.9,0.9],[0.8,0.9,0.1,0.85,0.95]]threshold = 0.8return = [[2,4],[11,13]]

The first camera is active on [1,4] and [10,13]. The second is active on [2,4] and [11,13]. Their closed intersections are [2,4] and [11,13].

Example 3

timestamps = [[1,5,9],[5,6]]intensities = [[0.2,0.8,0.1],[0.9,0.1]]threshold = 0.8return = [[5,5]]

Each camera has an active period containing only timestamp 5, so their closed intersection is the singleton period [5,5].

Constraints

  • 1 <= timestamps.length == intensities.length <= 20
  • For every camera c, timestamps[c].length == intensities[c].length.
  • The total number of readings across all cameras is at most 200000.
  • Each camera's timestamps are strictly increasing integers between 0 and 10^9.
  • 0.0 <= intensities[c][i] <= 1.0 and 0.0 <= threshold <= 1.0.

Similar questions at other companies

  • Meeting Rooms IIUber · PHONE SCREENUber interview questions
  • Meeting Rooms IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Common Camera Motion IntervalsVerkada · PHONE SCREENVerkada interview questions
  • Intersect Two Sorted Interval ListsByteDance · PHONE SCREENByteDance interview questions
  • Meeting Rooms IIWalmart · PHONE SCREENWalmart interview questions
  • Intersect Two Interval ListsSuperhuman · PHONE SCREENSuperhuman interview questions
  • Earliest Common Meeting SlotAdobe · PHONE SCREENAdobe interview questions
  • Intersections of Two Interval ListsDatadog · PHONE SCREENDatadog interview questions
  • Interval List IntersectionsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Minimum Machines for TasksExpedia · OAExpedia interview questions
See Serval hiring insights
Saved
class Solution {
    public List<List<Integer>> findSharedActivityPeriods(int[][] timestamps, double[][] intensities, double threshold) {
        // Write your code here.
    }
}
Checking account…