Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 미국 학교 도시락
- 고래 투어
- 너츠 배리 팜
- 미국 초등학교 점심
- Keurig
- 이진트리
- 오렌지 카운티 가볼만한 곳
- 켈리포니아 사이언스 센터
- Orange County Medium of Art
- John's Incredible Pizza
- California Sicense Center
- Whole Food
- 미국 골프
- Mermaid Beach
- leetcode
- OCMA
- 머메이드 비치
- 어바인 스펙트럼 센터
- 디스커버리 큐브
- 점심 식사 온라인 주문
- binary tree
- Irvine Spectrum Center
- Midway Museum
- chatGPT
- 미국 초등학교 점심식사 도시락
- Eisenhower Park
- Brea Mall
- Discovery Cube Orange County
- 미국 2주간 무료 로밍
- 아이젠하워 공원
Archives
- Today
- Total
Coder
[LeetCode] 145. Binary Tree Postorder Traversal 문제 풀이 본문
이진 트리(Binary Tree)의 값을 후위 순회(Postorder Traversal)하면서 값을 반환하는 문제입니다.
LeetCode : https://leetcode.com/problems/binary-tree-postorder-traversal/description/
Code(Python)
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def postorderTraversal(self, root):
"""
:type root: TreeNode
:rtype: List[int]
"""
res = []
def postorder(root):
if root:
if root.left:
postorder(root.left)
if root.right:
postorder(root.right)
res.append(root.val)
postorder(root)
return res