Created
November 6, 2018 14:55
-
-
Save arpi-r/48641115241238c84458bec167ae09bb to your computer and use it in GitHub Desktop.
codebuddy week8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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