knakul853

Untitled

Jul 22nd, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. /**
  2. knakul853
  3.  */
  4. class Solution {
  5. public:
  6.     bool isSameTree(TreeNode* p, TreeNode* q) {
  7.        
  8.         if(p == NULL || q == NULL)return p==q;
  9.        
  10.           if(p->val == q->val){
  11.              
  12.               return isSameTree(p->left, q->left) && isSameTree(p->right, q->right);
  13.              
  14.           }
  15.         return false;
  16.  
  17.     }
  18.    
  19.    
  20. };
Add Comment
Please, Sign In to add comment