← Questions
Total covered time per session from overlapping clips
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A coding interview question asked in Nuro's technical phone screen, last asked Jul 2025. It tests intervals, pandas and data manipulation.
A dataset of autonomous-driving clips stores one time interval per row. Clips from the same run can overlap, repeat or leave gaps. For each run, compute the total time covered by its clips, counting overlapping time once. Write it in SQL, then in Python.
Interface
Unless you agree on a different interface with the interviewer, assume:
- Table
clips(set_id INT, run_id VARCHAR, start_time INT, end_time INT, set_number INT); times are offsets in seconds, intervals are half-open[start_time, end_time)withend_time > start_time. - SQL: return
run_id, cumulative_unique_time. - Python:
unique_time(rows: list[tuple[str, int, int]]) -> dict[str, int], taking(run_id, start_time, end_time).
Example
run 20250101_122334: [58, 70), [57, 69), [55, 72), [56, 71), [80, 100)
run 20250102_101010: [43, 62)
20250101_122334 -> 37 # [55, 72) is 17, [80, 100) is 20
20250102_101010 -> 19
[0, 10) and [10, 15) in one run -> 15 # touching intervals don't overlap
Constraints
- Millions of rows across many runs.
Clarifying questions
- Are intervals half-open or closed?
- Group by run, or by set within a run?
- Can
end_timebe missing or beforestart_time? - Which SQL dialect (window functions available)?
What a strong answer covers
- Python: group by run, sort by start, merge while tracking the current end, add up the merged lengths; O(n log n).
- SQL with "gaps and islands": order by
start_timewithin each run, compute the running maximum ofend_timeover previous rows, start a new island whenstart_timeis greater than that maximum, then sumMAX(end) - MIN(start)per island. - Handling duplicates and fully contained intervals, and touching intervals under half-open semantics.
- Checking the SQL and Python results against each other on the same data.
Follow-ups
- Also return, per run, the number of seconds covered by two or more clips.
- Compute coverage per run per minute bucket.
- The table is huge and partitioned by date. How does the query scale?
Where it's asked
- Nuro · Technical phone screen · Last asked Jul 2025
What it tests
intervals · pandas · data manipulation
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
