solution:
vector<string> binaryTreePaths(TreeNode* root) {
vector<string> res;if(root==NULL)
return res;
string path="";
helper(path,res,root);
return res;
}
void helper(string path,vector<string>& res,TreeNode* root){
if(root==NULL){
return;
}else if(root->left==NULL&&root->right==NULL){
stringstream ss;
string s;
ss << root->val;
ss >> s;
path=path+s;
res.push_back(path);
return;
}
stringstream ss;
string s;
ss << root->val;
ss >> s;
path=path+s;
helper(path+"->",res,root->left);
helper(path+"->",res,root->right);
}