Recently I gave a phone screen for Amazon SDE1 position at Seattle.
There was a hacker rank assesment , before this round.
Phone Screen Question:
Given 2 n-ary trees, find all the pairs of nodes, one from each tree, whose values add up to a target sum.
My Approach:
I flattened both the trees doing BFS.
I wrote a function that returns a list of nodes for the input tree.
Thus reduced to 2 sum and solved it. Not sure if this approach was correct.
Kindly share if you have better ways to solve it.
Thanks.