leetcode+二叉树中序遍历

点击打开链接
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long
#define inf 0x3f3f3f3f
#define mod 1e9+7
using namespace std;
struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
class Solution {
public:
    vector ret;
    vector inorderTraversal(TreeNode* root) {
        if(root!=NULL){
            inorderTraversal(root->left);
            ret.push_back(root->val);
            inorderTraversal(root->right);
        }
        return ret;
    }
};
int main()
{
    Solution temple;
    return 0;
}

你可能感兴趣的:(Leetcode)