Function to find wether a node exists in a tree or not.
| 10 | |
| 11 | //Function to find wether a node exists in a tree or not. |
| 12 | bool find(TreeNode* root,int x) { |
| 13 | if(!root) return 0; |
| 14 | if(root->val==x) return 1; |
| 15 | return (find(root->left,x)|find(root->right,x)); |
| 16 | } |
| 17 | |
| 18 | // Recursive function for the solution |
| 19 | TreeNode* solve(TreeNode* root, int B, int C) { |