Created
August 8, 2017 02:55
-
-
Save cixuuz/67ed89f18433412466970f95d1f7836c to your computer and use it in GitHub Desktop.
[101. Symmetric Tree] #leetcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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