Code Room
CodingMedium
Question
Given `preorder` and `inorder` traversals of a binary tree with distinct values, reconstruct the tree and return its `postorder` traversal as a list. Both inputs describe the same tree and have equal length. `0 <= length <= 3000`.
Implement
pre_in_to_post(preorder: list[int], inorder: list[int]) → list[int]Examples
in
[[3,9,20,15,7],[9,3,15,20,7]]out[9,15,7,20,3]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.