Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- void f(TreeNode* root, int &count){
- if(root==NULL)return;
- f(root->left,count);
- count++;
- f(root->right,count);
- return;
- }
- int countNodes(TreeNode* root) {
- int count = 0;
- f(root,count);
- return count;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement