Facebook | Phone | Binary Tree Preorder Iterator

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-05-15Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: unknown
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

Implement a preorder iterator for a Binary Tree, need to be O N time and space needs to be less than O(N) or O(1).

It needs to have the next and hasNext method.

Similar question: https://leetcode.com/problems/binary-search-tree-iterator/

Comments