Skip to content

Instantly share code, notes, and snippets.

@arpi-r
Created November 6, 2018 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arpi-r/48641115241238c84458bec167ae09bb to your computer and use it in GitHub Desktop.
Save arpi-r/48641115241238c84458bec167ae09bb to your computer and use it in GitHub Desktop.
codebuddy week8
# Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param A : root node of tree
# @param B : root node of tree
# @return an integer
def check(self,A,B):
if A==None and B==None:
return 1
if A==None and B!=None:
return 0
if A!=None and B==None:
return 0
if A.val==B.val:
l=self.check(A.left,B.left)
r=self.check(A.right,B.right)
return l and r
else:
return 0
def isSameTree(self, A, B):
return self.check(A,B)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment