← Back to problems LC 114 →

Flatten Binary Tree to Linked List

LeetCode 114 • Medium • Trees • Anduril

Flatten a binary tree to a right-linked list in preorder, in-place. Demo: 1→2→3→4→5.

TimeO(n)visit each node once
SpaceO(h)explicit stack
Current
Prev
Tree
Flat spine
stack
prev
node
spine
Ready
Press Play to walk the algorithm.