Clarification about requirements. Is it preorder or level traversal?


  • 0
    C

    Both implementation of Level Traversal and Pre-Order Traversal can pass the OJ. However, OJ's serialization is apparently level order traversal. So pre-order should not pass the test case.

    I would suggest split this question into two, one for level traversal, and one for pre-order/in-order etc.


  • 0

    Why should pre-order not pass? We're even explicitly encouraged to be creative and not necessarily use LeetCode's format.


  • 0
    C

    Agree with you that multiple methods should be used, I read most of your posts and liked them. But I think it would be better this question divided into a few smaller ones just to help us to understand tree structures better. pre/in/post-order, level traversal's serialization have different relation to array index. So when it comes to algorithm like implementing heap in terms of array, understanding how level traversal relates to index is quite helpful.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.