MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / find

Function find

InterviewBit_problems/LeastCommonAncestor/solution.cpp:12–16  ·  view source on GitHub ↗

Function to find wether a node exists in a tree or not.

Source from the content-addressed store, hash-verified

10
11//Function to find wether a node exists in a tree or not.
12bool 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
19TreeNode* solve(TreeNode* root, int B, int C) {

Callers 1

lcaMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected