145-Binary-Tree-Postorder-Traversal
Sat 17 May 2025
https://leetcode.com/problems/binary-tree-postorder-traversal
import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
def postorderTraversal(self, root: Optional[TreeNode]) -> List[int]:
ans = []
def postorder(root: Optional[TreeNode]) -> None:
if not root:
return
postorder(root.left)
postorder(root.right)
ans.append(root.val)
postorder(root)
return ans
new Solution().postorderTraversal()
Score: 5
Category: leetcode