Example serialization
Input
build_tree_from_list([1,2,3,None,4,5])
Output
1,2,3,null,4,5
Level-order: 1,2,3,null,4,5,null,... Trim trailing nulls -> '1,2,3,null,4,5'.
Full lesson preview
Convert a binary tree to a compact level-order string representation.
Problem statement
Task
Examples
Input
build_tree_from_list([1,2,3,None,4,5])
Output
1,2,3,null,4,5
Level-order: 1,2,3,null,4,5,null,... Trim trailing nulls -> '1,2,3,null,4,5'.
Input format
Output format
Constraints
Samples
Input
build_tree_from_list([1,2,3,4,5,6,7])
Output
1,2,3,4,5,6,7
Perfect binary tree serializes without 'null's.