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