Untitled
unknown
c_cpp
2 years ago
451 B
4
Indexable
bool findElement(TreeNode *root, int key, vector<int> &path) { if (root == NULL) return false; path.push_back(root -> val); if (root -> val == key || findElement(root -> left, key, path) || findElement(root -> right, key, path)) return true; path.pop_back(); return false; } vector<int> Solution::solve(TreeNode* A, int B) { vector<int> path; findElement(A, B, path); return path; }
Editor is loading...