Back to problems

Implement list cloning and k-frequency finder

Object-Oriented Programming · Meta · Medium

Problem 1: Deep Copy a Linked List with Extra Pointers Given a linked list in which every node has a next pointer and a random pointer that can reference any node or null, produce a deep copy. The copied nodes must be entirely independent from the original list. Approach 1: Two-Pass Hash Map The hard part is not copying next; it is resolving random. If we first copy all nodes, we still need a way to know, for any original node, which copy corresponds to it. That problem…

Checking your access…