Master Data Structures & Algorithms For FREE at AlgoMap.io!
@christianjt70185 ай бұрын
I was able to solve this one by myself but I like your solution a lot more, thanks for sharing!
@GregHogg5 ай бұрын
That's awesome!
@TheResponsibleDude4 ай бұрын
Was able to do this in O(1) space complexity by pointing original node's next to new node. And we can go back and forth
@RakeshPandrinki-k6l3 ай бұрын
this is brilliant solution
@GarouNguyen5 ай бұрын
why return old_to_new[head] hash map not the new_node you just create?
@omkarwalunj67203 ай бұрын
old_to_new[head] will return the value of HashMap which points to the head of new list, as we are mapping original list to the new (copied) list in first pass and then creating the new link list in second pass, so when we return old_to_new[head] it will give head of the new list
@shreehari25899 ай бұрын
Please do clone graph next
@GregHogg7 ай бұрын
Sorry for the slow reply but hopefully you saw I did do that problem or you figured it out before that haha