二叉树遍历的应用
struct node {
int val;
node *left, *right;
};
int dfs(node *root) {
if (!root) return 0;
if (root->left && root->right) return1;
return dfs(root->left) + dfs(root->right);
}
二叉树遍历的应用
struct node {
int val;
node *left, *right;
};
int dfs(node *root) {
if (!root) return 0;
if (root->left && root->right) return1;
return dfs(root->left) + dfs(root->right);
}