Can i do it like this way about Binary Tree Inorder Traversal(0ms)?


  • -2
    T

    class Solution {
    public:
    vector<int> temp;
    void middle_order(TreeNode* root_t){
    if(root_t){
    if(root_t->left)middle_order(root_t->left);
    temp.push_back(root_t->val);
    if(root_t->right)middle_order(root_t->right);
    };
    };
    vector<int> inorderTraversal(TreeNode* root) {
    middle_order(root);
    return temp;
    }

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.