Clone Records with Random Links
Deep-copy records that link to each other: make every copy first, then wire the links.
The problem
Implement wire_cloned_records(records). Each record is a list [label, random_index]: random_index is the position of the record it links to (possibly itself), or -1 when it links to nothing. Return a copy of the whole structure: a new outer list with a new [label, random_index] list for every record, in the same order, so that changing the copy never changes the input. For example, [["a", 2], ["b", -1], ["c", 0]] gives [["a", 2], ["b", -1], ["c", 0]] built from new lists. Do not return or reuse any of the input's inner lists.
Starter code
def wire_cloned_records(records):
passPublic examples
records = [["a", 2], ["b", -1], ["c", 0]]gives[["a", 2], ["b", -1], ["c", 0]]records = [["only", 0]]gives[["only", 0]]
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
