> I'll be the contrarian and claim that inverting a binary tree is a perfectly reasonable interview question.
The fact that so many people in the previous discussion could not even tell what that means is a very bad sign.
The fact that so many people in the previous discussion could not even tell what that means is a very bad sign.
struct node {
struct node *left_node;
struct node *right_node;
int val;
};
struct reversed_node {
struct reversed_node *right_node;
struct reversed_node *left_node;
int val;
};
No? You then just have a different mapping for the exact same data, no traversal needed.