Facebook | Phone screen | Serialize and deserialize binary tree
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2019-04-24Added By Anonymous
Source: Link
Company: Meta (Facebook)
Role: e3
Interview Stage: Phone Screen
Location: unknown
Year: unknown
Original Post Content:
Status: New Grad
Given the root to a binary tree, serialize to a List<Integer> and deserialize back to the original tree.
Easy question that can run in O(N) time/space. I mentioned using a Deque to build back the tree for easier implementation at the cost of additional O(N) time/space but I went for the optimized method using the original List<Integer>. I missed a bug that should've kept track of a global index for the List<Integer> during recursion and I could not fix in time. It was an easy one line add of code though.
Overall very pleasant experience and I hope I somehow advance despite the small bug.