Flatten Binary Tree to Linked List

Medium

📝 Description

Flatten a binary tree to a linked list in-place

Input Format

Binary tree represented as list (level-order)

Output Format

Flattened linked list

Constraints

Number of nodes ≤ 2000

🔍 Sample Input

[1,2,5,3,4,null,6]
            

✅ Sample Output

[1,null,2,null,3,null,4,null,5,null,6]
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run