Weird One array Python Method


  • 0

    '''
    class Solution(object):
    def inorderTraversal(self, root):
    """
    :type root: TreeNode
    :rtype: List[int]
    """
    if root is None:
    return []
    stack = [root]
    while True:
    b = True # break
    for i in range(len(stack)):
    if not isinstance(stack[i], int):
    node = stack[i]
    del stack[i]
    temp = []
    if node.left is not None:
    temp.append(node.left)
    temp.append(node.val)
    if node.right is not None:
    temp.append(node.right)
    stack[i: i] = temp
    b = False
    break
    if b:
    break
    return stack
    '''


Log in to reply
 

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