regarding c++ solution, I have a vector of int, and each node I push the root->val and then recurse to the root->left and root->right
and then I pop_back on backtracking, so why the time complexity is O(n^2)? while at each node I push once and pop once
Type your question above this line.
Course: https://www.educative.io/collection/5668639101419520/5671464854355968
Lesson: https://www.educative.io/collection/page/5668639101419520/5671464854355968/5714315743068160