일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 밴픽
- DWG
- Python Implementation
- 109. Convert Sorted List to Binary Search Tree
- Class
- shiba
- 43. Multiply Strings
- 315. Count of Smaller Numbers After Self
- Protocol
- 30. Substring with Concatenation of All Words
- Decorator
- Substring with Concatenation of All Words
- t1
- Python Code
- data science
- attribute
- kaggle
- 시바견
- Generator
- 운영체제
- Regular Expression
- LeetCode
- 컴퓨터의 구조
- 파이썬
- 715. Range Module
- iterator
- 프로그래머스
- Convert Sorted List to Binary Search Tree
- Python
- concurrency
Archives
- Today
- Total
목록129. Sum Root to Leaf Numbers (1)
Scribbling
LeetCode: 129. Sum Root to Leaf Numbers
DFS로 푼다. # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def sumNumbers(self, root: Optional[TreeNode]) -> int: self.sum = 0 self.dfs(root, '0') return self.sum def dfs(self, node, num: str): if node.left == None and node.right == None: self.sum += int(num + str(nod..
Computer Science/Coding Test
2021. 11. 10. 20:36