/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
vector<int> inorderTraversal(TreeNode* root) {
vector<int> v;
if (root) {
inOrder(root, v);
}
return v;
}
private:
void inOrder(TreeNode* root, vector<int>& v) {
if (root) {
if (root->left) {
inOrder(root->left, v);
}
v.push_back(root->val);
if (root->right) {
inOrder(root->right, v);
}
}
}
};