Yosgi is a software engineer in Auckland with 9+ years of experience across product engineering, frontend architecture, full-stack systems, digital twins, and AI platform work.
Time: 30 minutes Serialization is simple and can be solved using BFS Deserialization requires the use of the properties of a binary tree, that is, the child nodes of the i-th node are (i + 1) * 2 - 1 …
Time: 25 minutes In fact, this is a relatively common DFS type question. The reason why it took so long is because there was a problem in judging the boundary value. When starting from the root, since …
When traversing a binary tree in front, middle, or post-order, we use a stack to simplify operations. This is because they are all recursive structures of DFS, which means processing from bottom to …
1h The order of in-order traversal is left - right - center recursion It’s very easy with recursion var postorderTraversal = function(root) { var res = [] if (!root) return res var travel = function …
10min The order of pre-order traversal of a binary tree is center-left-right First traverse all root nodes and left nodes, then process the right node It can be seen that this is a recursive behavior. …
30min The order of in-order traversal is left - middle - right recursion It’s very easy with recursion var inorderTraversal = function(root) { var res = [] if (!root) { return res } var travel = …
Time: 40 minutes ####105. Construct a binary tree from pre-order and in-order traversal sequences recursion Pre-order traversal: center-left-right In-order traversal: left-middle-right Therefore, we …