-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Labels
enhancementNew feature or requestNew feature or requesttypescriptAdventure Pack TypeScript issueAdventure Pack TypeScript issue
Description
Similar to #157, but level order! Since for level order, the level of the node is often important I think a good API might be roughly:
function traverseLevelOrder<T>(root: T | null | undefined): Generator<T[], void, void>;In other words, we can yield an array of the nodes on each level.
Why a generic function?
While investigating how linked lists work on LeetCode, I noticed that the objects we get aren't necessarily instances of the listed classes like ListNode or TreeNode. So rather than writing a function that works on only TreeNode objects, we should write a function that works on anything that has a left and a right property. #157 offers some examples of how to do this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesttypescriptAdventure Pack TypeScript issueAdventure Pack TypeScript issue