Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Vishruth-S/CompetitiveCode
/ lca
Method
lca
InterviewBit_problems/LeastCommonAncestor/solution.cpp:37–44 ·
view source on GitHub ↗
Source
from the content-addressed store, hash-verified
35
36
37
int Solution::lca(TreeNode* A, int B, int C) {
38
39
if(find(A,B) && find(A,C)) { //If both the given nodes exists in the tree
40
return solve(A,B,C)->val;
41
} else {
42
return -1; // Else return -1
43
}
44
}
Callers
nothing calls this directly
Calls
2
find
Function · 0.85
solve
Function · 0.70
Tested by
no test coverage detected