101 Symmetric tree

class Solution:
def isSymmetric(self, root: Optional[TreeNode]) -> bool:
if root:
return self.helper(root.left,root.right)
else:
return False
def helper(self,n1,n2):
if n1==None or n2==None :
return n1==n2
if n1.val != n2.val:
return False
return (self.helper(n1.left,n2.right) and self.helper(n1.right,n2.left))

--

--

--

Tech-Enthusiast, Coder,Explorer,Geeky,Software Engineer |A piece of code delivers everything that you need. The world is all about codes.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Pass AWS Certified Solutions Architect — Associate exam easy way!

64Base: 1.0.1 VM — Vulnhub.com

ArgoCD + Minikube + Ngrok + Github Webhook

3 problem-solving skills I learned as a maintenance engineer that you can use right now

Shoot Down Front-End Fatigue With Tracer Bullets

Leverage private packages when training and deploying models

Got ‘Error: ENOSPC: System limit for number of file watchers reached’ Error?

A Beginner’s Guide to Kubeflow on Google Cloud Platform

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dhanarajappu

Dhanarajappu

Tech-Enthusiast, Coder,Explorer,Geeky,Software Engineer |A piece of code delivers everything that you need. The world is all about codes.

More from Medium

236. Lowest Common Ancestor of a Binary Tree

Major shifts in IT workforce — Europe

Workforce image — hands

Peak: Secrets From the New Science of Expertise: Summary and Notes

What’s an example of a web3 app that exists today?