标签:onclick number eve code 思路 左右子树 要求 表示 path
要求
思路
示例
1 class Solution { 2 public: 3 vector<string> binaryTreePaths(TreeNode* root) { 4 5 vector<string> res; 6 7 if( root == NULL ) 8 return res; 9 10 if( root->left == NULL && root->right == NULL){ 11 res.push_back( to_string(root->val) ); 12 return res; 13 } 14 15 vector<string> leftS = binaryTreePaths(root->left); 16 for( int i = 0 ; i < leftS.size() ; i ++ ) 17 res.push_back( to_string(root->val) + "->" + leftS[i]); 18 19 vector<string> rightS = binaryTreePaths(root->right); 20 for( int i = 0 ; i < rightS.size() ; i ++ ) 21 res.push_back( to_string(root->val) + "->" + rightS[i]); 22 23 return res; 24 } 25 };
相关
标签:onclick number eve code 思路 左右子树 要求 表示 path
原文地址:https://www.cnblogs.com/cxc1357/p/12683870.html