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