weikee94 / leetcode

A leetcode a day keeps unemployment away 😎
1 stars 0 forks source link

02 哈希表、映射、集合;树、二叉树、二叉搜索树 #1

Open weikee94 opened 4 years ago

weikee94 commented 4 years ago

Tree

Screenshot 2020-08-09 at 10 31 30 PM

示例代码


def preorder(self, root)
  if root:
    self.traverse.append(root.val)
    self.preorder(root.left)
    self.preorder(root.right)

def inorder(self, root)
  if root:
    self.inorder(root.left)
    self.traverse.append(root.val)
    self.inorder(root.right)

def postorder(self, root)
  if root:
    self.postorder(root.left)
    self.postorder(root.right)
    self.traverse.append(root.val)
weikee94 commented 4 years ago

Map

The difference from a regular Object:

Set