题目链接:https://leetcode.com/problems/binary-tree-inorder-traversal/?tab=Description
题意:中序遍历。
1 class Solution { 2 public: 3 vector<int> ret; 4 void dfs(TreeNode* rt) { 5 if (!rt) return; 6 dfs(rt -> left); 7 ret.push_back(rt -> val); 8 dfs(rt -> right); 9 } 10 vector<int> inorderTraversal(TreeNode* rt) { 11 ret.clear(); 12 dfs(rt); 13 return ret; 14 } 15 };