LeetCode题目-145

首页 编程分享 LEET_CODE 正文

leetCode 转载 编程分享 2020-03-22 03:17:42

简介 LeetCode题目-145


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


✏描述

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

✏题目实例

       /**
         * @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;
        }

转载链接:https://leetcode.cn/


Tags:


本篇评论 —— 揽流光,涤眉霜,清露烈酒一口话苍茫。


    声明:参照站内规则,不文明言论将会删除,谢谢合作。


      最新评论




ABOUT ME

Blogger:袅袅牧童 | Arkin

Ido:PHP攻城狮

WeChat:nnmutong

Email:nnmutong@icloud.com

标签云