Update the Optional alias of Python codes.

This commit is contained in:
Yudong Jin
2023-01-09 02:49:34 +08:00
parent 4d01436138
commit 97ee638d31
8 changed files with 37 additions and 45 deletions

View File

@ -5,8 +5,6 @@ Author: a16su (lpluls001@gmail.com)
"""
import sys, os.path as osp
import typing
sys.path.append(osp.dirname(osp.dirname(osp.abspath(__file__))))
from include import *
@ -14,7 +12,7 @@ from include import *
res = []
""" 前序遍历 """
def pre_order(root: typing.Optional[TreeNode]):
def pre_order(root: Optional[TreeNode]):
if root is None:
return
# 访问优先级:根结点 -> 左子树 -> 右子树
@ -23,7 +21,7 @@ def pre_order(root: typing.Optional[TreeNode]):
pre_order(root=root.right)
""" 中序遍历 """
def in_order(root: typing.Optional[TreeNode]):
def in_order(root: Optional[TreeNode]):
if root is None:
return
# 访问优先级:左子树 -> 根结点 -> 右子树
@ -32,7 +30,7 @@ def in_order(root: typing.Optional[TreeNode]):
in_order(root=root.right)
""" 后序遍历 """
def post_order(root: typing.Optional[TreeNode]):
def post_order(root: Optional[TreeNode]):
if root is None:
return
# 访问优先级:左子树 -> 右子树 -> 根结点