Reported July 2025
Servaltwo pointers

Find Shared Camera Activity Periods

Reported by candidates from Serval's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Serval OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this Serval OA, reported in July 2025, is treating the readings as points instead of closed intervals. You get timestamped camera intensities, a threshold, and you must return the time periods where every camera is active at once. It's interval building plus interval intersection, and the edge cases are where people lose. Singleton runs, touching endpoints, and a camera with zero active periods all show up in the examples. If you blank on the intersection step, StealthCoder sits invisibly on your screen as a safety net during the live OA.

The problem

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.8
return = [[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.8
return = [[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.8
return = [[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.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Two stages. First, for each camera, scan once and build maximal runs where intensity >= threshold. An inactive reading closes the run. A single active reading becomes [t,t]. Second, intersect camera by camera using two pointers: keep a running list, intersect it with the next camera's list, take max of starts and min of ends, keep it if start <= end, then advance whichever interval ends first. The pitfall is using strict inequality, which kills the singleton [5,5] in Example 3. Another trap is bridging across an inactive reading just because timestamps look close. If any camera has no periods, return empty immediately. Finish by merging fragments that overlap or touch at an endpoint. Total work is linear in readings plus up to 20 passes. StealthCoder is your hedge if the pointer advance logic slips under live pressure.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Find Shared Camera Activity Periods cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder
⏵ The honest play

You've seen the question. Make sure you actually pass Serval's OA.

Serval reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Shared Camera Activity Periods FAQ

What's the trick to Find Shared Camera Activity Periods?+

Convert each camera into closed intervals first, then intersect them with two pointers. Intersection of [a,b] and [c,d] is [max(a,c), min(b,d)] when that start is <= that end. Advance the pointer whose interval ends earlier. Don't try to sweep raw readings across all cameras at once.

Why does Example 3 return [5,5]?+

Both cameras have an active run containing only timestamp 5. Closed intervals mean a single shared point counts. If you use a strict less-than when checking start versus end, you drop it and fail the case. Use <= everywhere.

Does a reading exactly equal to the threshold count as active?+

Yes. The problem says at least threshold, and Example 1 confirms it with 0.8 values included. Use >= when comparing. With doubles, compare directly against the given threshold. Don't add rounding tweaks that the problem didn't ask for.

Do I need to merge results at the end?+

The statement says to merge final closed fragments that overlap or touch at one endpoint. Add a last pass over the sorted result. If the next start <= the current end, extend the current end to the max. It's cheap and protects you on odd inputs.

How do I prepare for this in 48 hours?+

Practice two things: building runs from a filtered array and the two-pointer interval intersection. Write the intersection by hand until the pointer advance is automatic. Then test singletons, touching endpoints, an empty camera, and a single camera input. That covers nearly every failure mode here.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Serval.

OA at Serval?
Invisible during screen share
Get it