problem link=
solu=lass Solution {
public:
int ans = 0;
vector<int>postorder(TreeNode* root){
if(root == NULL)
return {-1, -1};
int left = postorder(root->left)[1] + 1;
int right = postorder(root->right)[0] + 1;
ans = max({ans, left, right});
return {left, right};
}
int longestZigZag(TreeNode* root) {
postorder(root);
return ans;
}
};
In this above solution can u plz tell me why is the root->left is taken at index 1 pos and the root->right is taken at index 0 position