Pair shards without conflict
A storage cluster mirrors every shard onto exactly one partner shard, so the shards split into pairs with nobody left over. rack_of[i] is the rack that shard i sits in, and two shards in the same rack may not be partners because a rack loses power as a unit. blocked lists further pairs written as two shard numbers that may not be partners, in either order, possibly more than once. Return every complete pairing as a list holding, for each shard in turn, the number of its partner. Sort the pairings in ascending order so the answer does not depend on how the search walked. Return an empty list when no pairing works, including when the shard count is odd. With no shards there is exactly one pairing, the empty one, so return a single empty plan. There are at most 14 shards.
list_replica_pairs(rack_of: list[int], blocked: list[list[int]]) → list[list[int]][[0,1],[]]out[[1,0]][[0,1,0,1],[]]out[[1,0,3,2],[3,2,1,0]][[0,0,1,1],[[0,2]]]out[[3,2,1,0]]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[[0,1],[]][[1,0]]not run yetsample[[0,1,0,1],[]][[1,0,3,2],[3,2,1,0]]not run yetsample[[0,0,1,1],[[0,2]]][[3,2,1,0]]not run yetsample