Easy to understand Python code, beats 96.42% Python submissions

  • 0
    class Solution(object):
        def inorderTraversal(self, root):
            if root == None: return []
            r = []; st = []; node = root
            while st:
                while node and node.left:
                    node = node.left
                node = st.pop()
                node = node.right
                if node: st.append(node)
            return r

Log in to reply

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