Created
July 20, 2019 00:19
-
-
Save zhangxiaomu01/19bdeb6bec3cf8fc92a288745b4f0563 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
private: | |
void dfs(vector<int>& res, TreeNode* root){ | |
if(root == nullptr) return; | |
dfs(res, root->left); | |
res.push_back(root->val); | |
dfs(res, root->right); | |
} | |
public: | |
vector<int> inorderTraversal(TreeNode* root) { | |
vector<int> res; | |
dfs(res, root); | |
return res; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment