Skip to content

[Tree Serialization] Construct Binary Tree from Preorder and Inorder Traversal #116

@sudosf

Description

@sudosf

Problem

Given preorder and inorder traversal arrays of a binary tree, construct and return the binary tree.

References

Difficulty

🟡 Medium

Companies

Amazon, Microsoft, Google

Notes

Language: Java
Preorder first element is always root. Find root in inorder to split left/right subtrees. Use a HashMap for O(1) inorder lookups.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dfsDepth-first searchmediumMedium difficultytreeTree problems

    Projects

    Status
    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions