목록binary Tree (3)
취미가 좋다
https://leetcode.com/problems/kth-smallest-element-in-a-bst/ Kth Smallest Element in a BST - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Solution class Solution: def kthSmallest(self, root, k): def rank(node, ans): if node.left and rank(node.left, ans): return True ans.append(n..
https://leetcode.com/problems/invert-binary-tree/ Invert Binary Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Solution from collections import deque class Solution: def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: if not root: return root d = deque() d..
https://leetcode.com/problems/binary-tree-right-side-view/ Binary Tree Right Side View - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com Solution # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left ..