my python solution


  • 0
    A
    """
    Solution with inorder traversal
    """
    class Solution(object):
        def kthSmallest(self, root, k):
            if root is None:
                return None
            result = []
            
            self.in_order(root, result)
            
            return result[k- 1]
            
        def in_order(self, root, result):
            if root:
                self.in_order(root.left, result)
                result.append(root.val)
                self.in_order(root.right, result)
            
            
    

Log in to reply
 

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