Mixed elements
Input
[1, [2, 3], 4]
Output
[1, 2, 3, 4]
The inner list [2, 3] is flattened into the outer list. Other elements stay the same.
Full lesson preview
Flatten only one level of nested lists, leaving deeper nested lists intact.
Problem statement
Task
Examples
Input
[1, [2, 3], 4]
Output
[1, 2, 3, 4]
The inner list [2, 3] is flattened into the outer list. Other elements stay the same.
Input format
Output format
Constraints
Samples
Input
[[1,2],[3],[4,5]]
Output
[1, 2, 3, 4, 5]
All inner lists are expanded into the returned list.