← Back to experiences
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/experiences/…$
Level: Junior-Level
Round: Online Assessment · Type: Coding · Difficulty: 6/10 · Duration: 60 min · Interviewer: Neutral
Topics: Interval Merging, Arrays, Algorithms
Location: San Francisco Bay Area
Interview date: 2025-12-28
Question: I was asked to calculate the total execution time of processes given their start and end times, merging overlapping intervals.
The problem involves calculating the total time during which at least one process is running, given a list of processes with their start and end times (inclusive). This requires merging overlapping intervals and summing their lengths.
` class Solution: def getExecutionTime(self, start, end): intervals = sorted(zip(start, end)) merged = []
for interval in intervals:
if not merged or interval[0] > merged[-1][1]:
merged.append(interval)
else:
merged[-1] = (merged[-1][0], max(merged[-1][1], interval[1]))
total_time = 0
for interval in merged:
total_time += interval[1] - interval[0] + 1
return total_time
`
Key points:
end - start + 1 (since inclusive).