Click here to see the full article post
That's not Morris traversal, since that doesn't destroy the tree (which yours does).
@ManuelP Thank you for your advice. Actually, I do not destroy the tree, I construct the tree just want to understand easier. but you are right, it is not an official way to explain this way
@monkeykingyan You do destroy the tree. When you're done, it's not the same as it was in the beginning. It's very different.
And btw it's not space complexity O(1). Because your ArrayList uses linear extra space (both extra capacity at all times, and duplicate space whenever it grows its capacity and copies its elements).
@flgt Yes, the example should be as same as the 3rd one, I will contact LeetCode to change it, thank you for letting me know
@ManuelP Yes, thank you for letting me know, Space Complexity should be O(n).
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.