bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
MediumTreesLC 114

Flatten Binary Tree to Linked List

Given the root of a binary tree, flatten the tree into a "linked list ": The "linked list " should use the same TreeNode class where the right child pointer points to the next node in the list and the left child pointer is always null. The "linked list " should be in the same order as a pre-order traversal of the binary tree.

Asked at 14 companies
AdobeAmazonApple
Hints
  • 1.Think about which data structure fits best
  • 2.Consider the time complexity of your approach
  • 3.Look for patterns in the constraints
LeetCode