I recently attended Amazon SDE2 phone interview. He introduced himself first and then asked me for my introduction.
He then jumped onto coding problem, He only asked me one problem. Statement is as follows:
There is a set of numbers given in an array. Two BST's have been formed from that set. Now we will be given these two tree's root node and we need to return boolean if they are same set elements or not.
So basically two tree's with this set : [1,3,4,5,6,7,9] can be: 5 3 7 1 4 6 8 and 4 3 6 1 null 5 7 9 (these two are level order traversal of BST). Please excuse if it's not appropriate as it's difficult to draw BST here.
These are two BST with same set elements. So true.
I gave him two approaches. One with doing XOR of elements of trees and other one with using set data structure. Not sure what he was expecting but got rejected. Bad part was that he wished me all the best for next round (LOL).
If you guys have any other approach. Please let me know. Thanks