Skip to content

Latest commit

 

History

History
40 lines (33 loc) · 1.15 KB

145.md

File metadata and controls

40 lines (33 loc) · 1.15 KB

✏️Leetcode基础刷题之(150. Evaluate Reverse Polish Notation)

2019-05-03 吴亲库里 库里的深夜食堂


✏️描述

使用非递归来完成二叉树的前序遍历。

✏️题目实例

       /**
         * @param TreeNode $root
         * @return Integer[]
         */
        function postorderTraversal($root) {
             $tree=[];
             $res=[];
            array_unshift($tree,$root);
            while(!empty($tree)){
                $node=array_shift($tree);
                if($node==null) continue;
                array_unshift($res,$node->val);
                array_unshift($tree,$node->left);
                array_unshift($tree,$node->right);
            }
            return $res;
        }

联系