leetcode 94.二叉树的中序遍历
vector<int> ans; void dfs(TreeNode* now){ if (now==nullptr) return ; dfs(now->left); ans.push_back(now->val); dfs(now->right); } class Solution { public: vector<int> inorderTraversal(TreeNode* root) { ans.clear(); dfs(root); return ans; } };

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号