Given a linked list which has the node structure as shown below:
class Node{
Node val; // note that the value also randomly points to some other node in the LL
Node next;
}
How would you duplicate this linked list ?
Hint: I used an external hashmap DS in my solution.
Better solution:
http://www.geeksforgeeks.org/a-linked-list-with-next-and-arbit-pointer/
class Node{
Node val; // note that the value also randomly points to some other node in the LL
Node next;
}
How would you duplicate this linked list ?
Hint: I used an external hashmap DS in my solution.
Better solution:
http://www.geeksforgeeks.org/a-linked-list-with-next-and-arbit-pointer/
Nice explanation with example. Thanks for sharing.
ReplyDeleteCheers,
http://www.flowerbrackets.com/addition-operation-bitwise-operators-java/