A simple inOrderSort python solution

  • 0

    Please share your thoughts on this: Looks like the traditional inOrder Traverse works here too

    class Solution(object):

    def kthSmallest(self, root, k):
        l = []
        self.inOrderSort( root, l)
        return l[k-1]
    def inOrderSort(self, node,  l):
        if node is not None:
            self.inOrderSort(node.left, l)  
            self.inOrderSort(node.right, l)

Log in to reply

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