일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Convert Sorted List to Binary Search Tree
- Class
- DWG
- 운영체제
- Substring with Concatenation of All Words
- 715. Range Module
- Python Code
- Generator
- Protocol
- 43. Multiply Strings
- Regular Expression
- 109. Convert Sorted List to Binary Search Tree
- Decorator
- 파이썬
- attribute
- 315. Count of Smaller Numbers After Self
- kaggle
- t1
- 프로그래머스
- 컴퓨터의 구조
- 밴픽
- LeetCode
- data science
- concurrency
- 30. Substring with Concatenation of All Words
- Python
- Python Implementation
- 시바견
- shiba
- iterator
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