Skip to content

Instantly share code, notes, and snippets.

@wohhie
Created July 10, 2021 16:59
Show Gist options
  • Select an option

  • Save wohhie/adcc571c22e44ba18a24b69d0a93912e to your computer and use it in GitHub Desktop.

Select an option

Save wohhie/adcc571c22e44ba18a24b69d0a93912e to your computer and use it in GitHub Desktop.
private int count_who_have_both_children(Node node){
int x, y;
if (node != null){
x = count_who_have_both_children(node.left);
y = count_who_have_both_children(node.right);
if (node.left != null && node.right != null){
return x + y + 1;
}else {
return x + y;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment