package com.fishercoder.solutions;

import com.fishercoder.common.classes.TreeNode;

/**
 * 101. Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).

For example, this binary tree [1,2,2,3,4,4,3] is symmetric:

    1
   / \
  2   2
 / \ / \
3  4 4  3

But the following [1,2,2,null,3,null,3] is not:

    1
   / \
  2   2
   \   \
   3    3

Note:
Bonus points if you could solve it both recursively and iteratively.
 */

public class _101 {
	public static class Solution1 {
		public boolean isSymmetric(TreeNode root) {
			if (root == null) {
				return true;
			}
			return isSymmetric(root.left, root.right);
		}

		private boolean isSymmetric(TreeNode left, TreeNode right) {
			if (left == null || right == null) {
				return left == right;
			}
			return left.val == right.val && isSymmetric(left.left, right.right) && isSymmetric(left.right, right.left);
		}
	}
}

@@ -86,429 +86,8 @@
 %0D%0A%0D%0A
-/**%0D%0A * 101. Symmetric Tree%0D%0A%0D%0AGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).%0D%0A%0D%0AFor example, this binary tree %5B1,2,2,3,4,4,3%5D is symmetric:%0D%0A%0D%0A    1%0D%0A   / %5C%0D%0A  2   2%0D%0A / %5C / %5C%0D%0A3  4 4  3%0D%0A%0D%0ABut the following %5B1,2,2,null,3,null,3%5D is not:%0D%0A%0D%0A    1%0D%0A   / %5C%0D%0A  2   2%0D%0A   %5C   %5C%0D%0A   3    3%0D%0A%0D%0ANote:%0D%0ABonus points if you could solve it both recursively and iteratively.%0D%0A */%0D%0A%0D%0A
 publ
@@ -103,17 +103,20 @@
 _101 %7B%0D%0A
-%09
+    
 public s
@@ -140,18 +140,24 @@
 ion1 %7B%0D%0A
-%09%09
+        
 public b
@@ -189,27 +189,36 @@
 de root) %7B%0D%0A
-%09%09%09
+            
 if (root == 
@@ -230,35 +230,65 @@
  %7B%0D%0A
-%09%09%09%09return true;%0D%0A%09%09%09%7D%0D%0A%09%09%09
+                return true;%0D%0A            %7D%0D%0A            
 retu
@@ -331,17 +331,29 @@
 );%0D%0A
-%09%09%7D%0D%0A%0D%0A%09%09
+        %7D%0D%0A%0D%0A        
 priv
@@ -410,19 +410,28 @@
 ght) %7B%0D%0A
-%09%09%09
+            
 if (left
@@ -464,12 +464,24 @@
  %7B%0D%0A
-%09%09%09%09
+                
 retu
@@ -503,17 +503,35 @@
 t;%0D%0A
-%09%09%09%7D%0D%0A%09%09%09
+            %7D%0D%0A            
 retu
@@ -639,14 +639,23 @@
 );%0D%0A
-%09%09%7D%0D%0A%09
+        %7D%0D%0A    
 %7D%0D%0A%7D

refactor 101