![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
Blssel
关注Deep Learning,Action Recognition,Video Understading,Tensorflow等,有任何学习上的问题欢迎大家发邮件和我交流:yinzhiyu17@mails.ucas.ac.cn
展开
-
[Leetcode] 143. Reorder List
题目描述Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You may not modify the values in the list’s nodes, only nodes itself may be changed.Example 1:Given 1-&g...原创 2019-06-21 16:18:32 · 108 阅读 · 0 评论 -
[LeetCode] 144. Binary Tree Preorder Traversal
题目描述分析二叉树前序遍历,非常简单,不过题目要求用递推法,不可用递归,不经常写的最好再熟悉下,虽然不难,面试中说不定会被问到。递推法只需额外开辟一个栈即可,每遍历完当前节点,按顺序将右孩子(如果有的话)和左孩子(如果有的话)依次入栈,下次遍历则直接从栈顶取就好,直到栈为空。codeclass Solution {public: vector<int> preorder...原创 2019-06-21 22:25:26 · 104 阅读 · 0 评论 -
[LeetCode] 145. Binary Tree Postorder Traversal
题目描述分析后序遍历即先访问左子树和右子树,再访问根节点。递归写法很简单,但题目要求用非递归写法。不是太容易写,面试时候说不定会问(感觉啥都会问emmm),代码如下,已注释关键部分,可以在理解的基础上加以记忆。class Solution {public: vector<int> postorderTraversal(TreeNode* root) { vector&l...原创 2019-06-22 22:28:03 · 228 阅读 · 0 评论 -
[LeetCode] 94. Binary Tree Inorder Traversal
题目描述## 分析中序遍历,依然让用非递归法。本题比较简单,只要看懂后续遍历的写法,中序就迎刃而解了。## codeclass Solution {public: vector<int> inorderTraversal(TreeNode* root) { vector<int> res; //存放结果 stack<TreeNode*> ...原创 2019-06-22 22:53:54 · 140 阅读 · 0 评论