The diagram below shows a simplified social network where each node represents a user.
Given a reference of a node, deep clone the social network and return a copy of the given node.
const clone = function(node) {
// Enter your logic here...
}
Examples:
Input: [[B, D], [A, C], [B, D], [A, C]]
Output: [[B, D], [A, C], [B, D], [A, C]]
Explanation: The cloned network has the 4 similar nodes as the original network.
Input: [[Vegeta, Piccolo], [Goku, Piccolo], [Goku, Vegeta]]
Output: [[Vegeta, Piccolo], [Goku, Piccolo], [Goku, Vegeta]]
Explanation: The cloned network has the 3 similar nodes as the original network.