Amazon Interview Question

Create copy of a binary tree where each node also has a random pointer to some other node of the same tree.

Interview Answer

Anonymous

Sep 11, 2020

Use map to store address of this node and corresponding node of new tree. Again traverse both trees and fill the random pointers by looking the corresponding nodes