class Solution {public: void binaryPath(TreeNode* root, vector& result, string path) { if (root == NULL) { return; } if (path.empty()) { path = to_string(root->val); } else { path += "->" + to_string(root-> val); } if (root->left == NULL && root->right == NULL) { result.push_back(path); return; } if (root->left) { binaryPath(root->left, result, path); } if (root->right) { binaryPath(root->right, result, path); } } vector binaryTreePaths(TreeNode* root) { vector result; string path; binaryPath(root, result, path); return result; }};