일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 30. Substring with Concatenation of All Words
- 컴퓨터의 구조
- Generator
- Python
- 운영체제
- 시바견
- concurrency
- Class
- Decorator
- kaggle
- DWG
- 109. Convert Sorted List to Binary Search Tree
- shiba
- Convert Sorted List to Binary Search Tree
- 밴픽
- Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
- Python Implementation
- t1
- attribute
- 715. Range Module
- 파이썬
- iterator
- Protocol
- 43. Multiply Strings
- LeetCode
- Regular Expression
- Python Code
- 프로그래머스
- data science
Archives
- Today
- Total
목록Kth Smallest Element in a BST (1)
Scribbling
LeetCode: 230. Kth Smallest Element in a BST
BST이기 때문에 Inorder-Traverse하면 된다. K번째 원소를 찾으면 순회를 중단한다. 때문에 O(K)이다. # 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 kthSmallest(self, root: Optional[TreeNode], k: int) -> int: self.ret = 0 self.k = k self.traverse(root) return self.ret # returns whether traverse ..
Computer Science/Coding Test
2021. 12. 14. 21:33