GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/python/100_Same_Tree.py at master · as802311/leetcode Expand file tree/ Copy path100_Same_Tree.pyMore file actions 25 lines (24 loc) · 657 Bytes / Copy path100_Same_Tree.pyFile metadata and controls25 lines (24 loc) · 657 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isSameTree(self, p, q): """ :type p: TreeNode :type q: TreeNode :rtype: bool """ if p == q: return True try: left = right = True if p.val == q.val: left = self.isSameTree(p.left, q.left) right = self.isSameTree(p.right, q.right) return (left and right) except: return False return False |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |