Skip to content

Instantly share code, notes, and snippets.

@cixuuz
Created August 8, 2017 02:55
Show Gist options
  • Select an option

  • Save cixuuz/67ed89f18433412466970f95d1f7836c to your computer and use it in GitHub Desktop.

Select an option

Save cixuuz/67ed89f18433412466970f95d1f7836c to your computer and use it in GitHub Desktop.
[101. Symmetric Tree] #leetcode
public class Solution {
public boolean isSymmetric(TreeNode root) {
if (root == null) return true;
return helper(root, root);
}
private boolean helper(TreeNode left, TreeNode right) {
return (left != null && right != null && left.val == right.val && helper(left.right, right.left) && helper(left.left, right.right)) || (left == null && right == null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment