Easy || 0 ms 100% (Fully Explained)(Java, C++, Python, JS, Python3)
Java Solution:\nRuntime: 0 ms, faster than 100.00% of Java online submissions for Symmetric Tree.\n\nclass Solution {\n    public boolean isSymmetric(TreeNode r
# **Java Solution:**\nRuntime: 0 ms, faster than 100.00% of Java online submissions for Symmetric Tree.\n```\nclass Solution {\n    public boolean isSymmetric(TreeNode root) {\n        // Soecial case...\n        if (root == null)\n\t\t    return true;\n        // call the function  recursively...\n\t    return isSymmetric(root.left, root.right);\n    }\n    // After division the tree will be divided in two parts...\n    // The root of the left part is rootleft & the root of the right part is rootright...\n    public boolean isSymmetric(TreeNode rootleft, TreeNode rootright) {\n        // If root of the left part & the root of the right part is same, return true...\n\t    if (rootleft == null && rootright == null) {\n\t\t    return true;\n\t    }\n        // If root of any part is null, then the binary tree is not symmetric. So return false...\n        else if (rootright == null || rootleft == null) {\n\t\t    return false;\n\t    }\n        // If the value of the root of the left part is not equal to the value of the root of the right part...\n        if (rootleft.val != rootright.val)\n\t\t    return false;\n        // In case of not symmetric...\n        if (!isSymmetric(rootleft.left, rootright.right))\n\t\t    return false;\n\t    if (!isSymmetric(rootleft.right, rootright.left))\n\t\t    return false;\n        // Otherwise, return true...\n        return true;\n    }\n}\n```\n\n# **C++ Solution:**\n```\nclass Solution {\npublic:\n    bool isSymmetric(TreeNode* root) {\n        // Special case...\n        if(root == nullptr) return true;\n        // Return the function recursively...\n        return isSymmetric(root->left,root->right);\n    }\n    // A tree is called symmetric if the left subtree must be a mirror reflection of the right subtree...\n    bool isSymmetric(TreeNode* leftroot,TreeNode* rightroot){\n        // If both root nodes are null pointers, return true...\n        if(!leftroot && !rightroot)  return true;\n        // If exactly one of them is a null node, return false...\n        if(!leftroot || !rightroot)  return false;\n        // If root nodes haven\'t same value, return false...\n        if(leftroot->val != rightroot->val)  return false;\n        // Return true if the values of root nodes are same and left as well as right subtrees are symmetric...\n        return isSymmetric(leftroot->left, rightroot->right) && isSymmetric(leftroot->right, rightroot->left);\n    }\n};\n```\n\n# **Python Solution:**\n```\nclass Solution(object):\n    def isSymmetric(self, root):\n        # Special case...\n        if not root:\n            return true;\n        # Return the function recursively...\n        return self.isSame(root.left, root.right)\n    # A tree is called symmetric if the left subtree must be a mirror reflection of the right subtree...\n    def isSame(self, leftroot, rightroot):\n        # If both root nodes are null pointers, return true...\n        if leftroot == None and rightroot == None:\n            return True\n        # If exactly one of them is a null node, return false...\n        if leftroot == None or rightroot == None:\n            return False\n        # If root nodes haven\'t same value, return false...\n        if leftroot.val != rightroot.val:\n            return False\n        # Return true if the values of root nodes are same and left as well as right subtrees are symmetric...\n        return self.isSame(leftroot.left, rightroot.right) and self.isSame(leftroot.right, rightroot.left)\n```\n            \n# **JavaScript Solution:**\nRuntime: 66 ms, faster than 97.80% of JavaScript online submissions for Symmetric Tree.\n```\nvar isSymmetric = function(root) {\n    // Special case...\n    if (!root)\n        return true;\n    // Return the function recursively...\n    return isSame(root.left, root.right);\n};\n// A tree is called symmetric if the left subtree must be a mirror reflection of the right subtree...\nvar isSame = function (leftroot, rightroot) {\n    // If both root nodes are null pointers, return true...\n    // If exactly one of them is a null node, return false...\n    // If root nodes haven\'t same value, return false...\n    if ((!leftroot && rightroot) || (leftroot && !rightroot) || (leftroot && rightroot && leftroot.val !== rightroot.val))\n        return false;\n    // Return true if the values of root nodes are same and left as well as right subtrees are symmetric...\n    if (leftroot && rightroot)\n        return isSame(leftroot.left, rightroot.right) && isSame(leftroot.right, rightroot.left);\n    return true;\n};\n```\n\n# **Python3 Solution:**\n```\nclass Solution:\n    def isSymmetric(self, root: Optional[TreeNode]) -> bool:\n        # Special case...\n        if not root:\n            return true;\n        # Return the function recursively...\n        return self.isSame(root.left, root.right)\n    # A tree is called symmetric if the left subtree must be a mirror reflection of the right subtree...\n    def isSame(self, leftroot, rightroot):\n        # If both root nodes are null pointers, return true...\n        if leftroot == None and rightroot == None:\n            return True\n        # If exactly one of them is a null node, return false...\n        if leftroot == None or rightroot == None:\n            return False\n        # If root nodes haven\'t same value, return false...\n        if leftroot.val != rightroot.val:\n            return False\n        # Return true if the values of root nodes are same and left as well as right subtrees are symmetric...\n        return self.isSame(leftroot.left, rightroot.right) and self.isSame(leftroot.right, rightroot.left)\n```\n**I am working hard for you guys...\nPlease upvote if you find any help with this code...**
['Recursion', 'C', 'Python', 'Java', 'Python3', 'JavaScript']