博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
94. Binary Tree Inorder Traversal(Tree)
阅读量:4181 次
发布时间:2019-05-26

本文共 328 字,大约阅读时间需要 1 分钟。

题目:求二叉树的中序遍历

思路:直接中序遍历。

class Solution {public:    vector
v; void inorder(TreeNode *root){ if(!root) return ; inorder(root->left); v.push_back(root->val); inorder(root->right); } vector
inorderTraversal(TreeNode* root) { inorder(root); return v; }};

转载地址:http://cirai.baihongyu.com/

你可能感兴趣的文章
实模式,保护模式与V86模式
查看>>
628. Maximum Product of Three Numbers(排序)
查看>>
Linux内核-------同步机制(二)
查看>>
面试题31-------连续子数组的最大和(数组)
查看>>
epoll 实现Chat
查看>>
21. Merge Two Sorted Lists(链表)
查看>>
2. Add Two Numbers(链表)
查看>>
637. Average of Levels in Binary Tree(Tree)
查看>>
226. Invert Binary Tree(Tree)
查看>>
328. Odd Even Linked List(链表)
查看>>
199. Binary Tree Right Side View(Tree)
查看>>
230. Kth Smallest Element in a BST(Tree)
查看>>
求字符串的最长回文串-----Manacher's Algorithm 马拉车算法
查看>>
回溯法常用的解题模板和常见题型
查看>>
深入分析Java I/O 的工作机制
查看>>
动态规划的套路----左神
查看>>
KMP算法简解
查看>>
左神算法课进阶版总结
查看>>
左神算法基础班总结
查看>>
Linux性能优化
查看>>