All problems
Contact Tracing Exposure Count
Problem
Count the distinct nodes exposed to a fixed infected set during a time window.
For snapshots with indices from start_time up to start_time + t - 1, every edge with an infected endpoint exposes the other endpoint. Return the number of exposed nodes that are not themselves infected. snapshots is a list of edge lists.
Hint
Contact tracing looks one snapshot window back from each confirmed case.
Test cases
case 1
in: [4,[[[0,1],[2,3]],[[1,2]],[[0,3]]],[0],0,2]
expected: 1
case 2
in: [4,[[[0,1],[2,3]],[[1,2]],[[0,3]]],[1],0,3]
expected: 2
case 3
in: [4,[[[0,1],[2,3]]],[0],0,1]
expected: 1
case 4
in: [4,[[[0,1]]],[2],0,1]
expected: 0
Starter codePython
def contact_tracing_count(n, snapshots, infected, start_time, t):
# Your code here
pass4 test cases · run your code against them in the editor