Code RoomReconstruct tree postorder
MediumPrep Room Coding #122

Reconstruct tree postorder

CodingAlgorithms & data structuresMid–Senior~30 min

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.

0:00 of about 30 min
InputExpectedGot
[[3,9,20,15,7],[9,3,15,20,7]][9,15,7,20,3]not run yetsample