Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3b984e0

Browse files
Day 10 Solutions
1 parent 65d583d commit 3b984e0

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* struct TreeNode {
4+
* int val;
5+
* TreeNode *left;
6+
* TreeNode *right;
7+
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
8+
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
9+
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
10+
* };
11+
*/
12+
class Solution {
13+
public:
14+
vector<int>ans;
15+
vector<int> inorderTraversal(TreeNode* root) {
16+
if(root==nullptr){
17+
return {};
18+
}
19+
inorderTraversal(root->left);
20+
ans.push_back(root->val);
21+
inorderTraversal(root->right);
22+
23+
return ans;
24+
}
25+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /