通过测试用例4/10; 骚操作。
/*
struct TreeNode {
int val;
struct TreeNode *left;
struct TreeNode *right;
TreeNode(int x) :
val(x), left(NULL), right(NULL) {
}
};*/
class Solution {
public:
vector<int> PrintFromTopToBottom(TreeNode* root) {
vector<int> v;
fun(root,v);
return v;
}
void fun(TreeNode* root,vector<int> &v){
if(root!=NULL){
v.push_back(root->val);
fun(root->left,v);
fun(root->right,v);
}
}
};