Skip to content

Commit 340a4a6

Browse files
committed
230
1 parent e23885a commit 340a4a6

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

145.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
public:
3+
vector<int> postorderTraversal(TreeNode* root) {
4+
vector<int>A;
5+
traversingtree(root,A);
6+
return A;
7+
}
8+
9+
void traversingtree(TreeNode * root,vector<int>&A){
10+
if(root==NULL){
11+
return ;
12+
}
13+
14+
traversingtree(root->left,A);
15+
16+
traversingtree(root->right,A);
17+
18+
A.push_back(root->val);
19+
}
20+
};

230.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public:
3+
int kthSmallest(TreeNode* root, int k) {
4+
vector<int>A;
5+
traversingtree(root,A);
6+
return A[k-1];
7+
}
8+
9+
void traversingtree(TreeNode * root,vector<int>&A){
10+
if(root==NULL){
11+
return ;
12+
}
13+
14+
traversingtree(root->left,A);
15+
A.push_back(root->val);
16+
traversingtree(root->right,A);
17+
18+
19+
}
20+
21+
22+
};

0 commit comments

Comments
 (0)