SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 413 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool checkNodes(struct TreeNode* a, struct TreeNode* b)
  2. {
  3.     if(a == NULL && b == NULL)
  4.     {
  5.         return true;
  6.     }
  7.    
  8.     if(a == NULL || b == NULL)
  9.     {
  10.         return false;
  11.     }
  12.     if(a->val != b->val)
  13.     {
  14.         return false;
  15.     }
  16.     return checkNodes(a->left, b->right) && checkNodes(a->right, b->left);
  17. }
  18. bool isSymmetric(struct TreeNode* root) {
  19.     if(root == NULL)
  20.     {
  21.         return true;
  22.     }
  23.     return checkNodes(root->left, root->right);
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top