Few days back I gave an online interview, in which I was asked the question(Not same though):
Given a binary tree, find the path between the largest and the smallest node?
Here, the node contains
Initially I thought of applying the dfs, followed by finding the max and the min node.
Then the interviewer told me to optimize it. Does anyone has any idea how to optimize it ?
Note: I got rejected in that round, but wanted to know the approach, so asking here.