No one has replied
As far as every possible solution will take minimum O(n) we can assume that it's constant space complexity
This is a very nice solution. I spent so much time on iterative pre-order but couldn't make it work. Seems for this problem you have to use some post-order like iterative traversal.
I must say, you are doing it in the wrong way.
retVec.insert(retVec.begin(),pCur->val); will take O(N) time to complete and you algorithm is basically O(N^2)
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.