You are viewing a single comment's thread. Return to all comments →
I dont think your solution would work if node 6(sample input) had a child in the left or right. Your solution would just skip 6 altogether and print 7 only.
That describes a different problem (or different constraints). The other solutions posted here and the editorial can help clarify what is wanted.