Question: What's the difference between #297 and #449


  • 0

    297. Serialize and Deserialize Binary Tree (Difficulty: Hard)
    449. Serialize and Deserialize BST (Difficulty: Medium)

    These two questions both are about serialisation of a binary tree. I see most solutions are similar (using preorder+resusion or BFS).
    For BST, its difficulty is medium, easier than a general binary tree. But I don't know why it is easier.

    Is there a better solution to serialize the BST rather than the same way to binary tree?
    Or the "easier" means serializing the BST is faster than the binary tree?


  • 1

    You could refer to this post:
    what's the difference between this and #297 ?

    Basically, this problem about BST is asking you to take advantage of BST's key sorting property compared to a generic binary tree. So the serialized result could be made more compact than in Problem 297.


Log in to reply
 

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