Simple C++ clean code


#1
bool checktree(TreeNode* A, int num){
if(A==NULL)
    return 0;
if(A->val == num)
    return 1;
if(checktree(A->left,num) or checktree(A->right,num))
    return 1;
return 0;

}
TreeNode* solvelca(TreeNode* A, int B, int C){
if(A==NULL) return NULL;
if(A->val == B or A->val == C)
return A;
TreeNode* leftN = solvelca(A->left,B,C);
TreeNode* rightN = solvelca(A->right,B,C);

if(leftN != NULL && rightN != NULL)
    return A;
if(leftN == NULL)
    return rightN;
else
    return leftN;

}
int Solution::lca(TreeNode* A, int B, int C) {
if(checktree(A,B) && checktree(A,C)){
TreeNode* ans = solvelca(A,B,C);
return ans->val;
}
else
return -1;
}