Python Solution (46ms)


  • 0
    H
    class Solution:
        # @param {TreeNode} root
        # @return {integer[]}
        def inorderTraversal(self, root):
            if not root:
                return []
    
            stack = []
            queue = []
            
            stack = self.getleft(root)
            
            while stack:
                node = stack.pop()
                if node:
                    queue.append(node.val)
                    stack.extend(self.getleft(node.right))
            return queue
    
        def getleft(self,root):
            s = []
            while root:
                s.append(root)
                root = root.left
            return s
    

Log in to reply
 

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