94-Binary Tree Inorder Traversal

题目:

Given a binary tree, return the inorder traversal of its nodes’ values.

For example:
Given binary tree [1,null,2,3],

1
    \
     2
    /
   3

return [1,3,2].

分析:
二叉树的中序遍历
思路1:
递归
思路2:
用Stack 实现

实现:
思路1:

class Solution {
public:
    vector<int> inorderTraversal(TreeNode* root) {

        vector<int> res;
        inorder(root,res);
        return res;

    }

    

你可能感兴趣的:(Leetcode,算法题解,c++,二叉树,遍历)