Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement