Very straightforward python solution


  • 0
    C
    class Solution(object):
        def kthSmallest(self, root, k):
            arr = []
            self.in_order(root, arr)
            return arr[k-1]
            
        def in_order(self, root, arr):
            if not root:
                return
            self.in_order(root.left, arr)
            arr.append(root.val)
            self.in_order(root.right, arr)
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.