Day i do not know

This commit is contained in:
Electrominch
2022-10-18 00:45:31 +03:00
parent 01c5720116
commit 284b6ff10c
72 changed files with 1256 additions and 12 deletions

View File

@@ -0,0 +1,20 @@
namespace _101._Symmetric_Tree;
public class Solution
{
public bool IsSymmetric(TreeNode root)
{
return Recursion(root.left, root.right);
}
private bool Recursion(TreeNode? left, TreeNode? right)
{
if ((left == null) != (right == null))
return false;
if (left == null || right == null)
return true;
if (left.val != right.val)
return false;
return Recursion(left.left, right.right) && Recursion(left.right, right.left);
}
}