From bb3fce98d6958d748514b540af8016965d983a25 Mon Sep 17 00:00:00 2001 From: deepti1408 Date: Tue, 21 Jul 2020 22:36:10 +0530 Subject: [PATCH] Problem 101. Symmetric Tree failing for test case [1,2,2,null,3,null,3]. Added the fix. --- Leetcode-oneStop.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Leetcode-oneStop.md b/Leetcode-oneStop.md index daa72bc..72d25b2 100644 --- a/Leetcode-oneStop.md +++ b/Leetcode-oneStop.md @@ -227,8 +227,10 @@ public boolean isSymmetricRecursive(TreeNode root) private boolean helperRecursive(TreeNode x, TreeNode y) { - if (x == null || y == null) // Base Case: Both or one is null, so true + if (x == null && y == null) // Base Case: Both are null, so true return true; + if (x == null || y == null) // Base Case: Passing above, here if any one is null, so false + return false; return (x.val == y.val && helperRecursive(x.left, y.right) && helperRecursive(x.right, y.left)); // Check if values match and 1.left matches with the 2.right and 1.right matches with 2.left }