#C12426. Flatten Nested List

    ID: 41852 Type: Default 1000ms 256MiB

Flatten Nested List

Flatten Nested List

You are given a nested list that can contain integers or other nested lists of arbitrary depth. Your task is to flatten this nested list into a single list of integers while preserving the order of appearance.

For example, given the nested list:

\([1, 2, [3, 4, [5, 6]], 7]\)

the flattened list is:

\(1\ 2\ 3\ 4\ 5\ 6\ 7\)

Note: The input will be provided in JSON format from stdin. The output should be printed to stdout as space-separated integers.

inputFormat

The input consists of a single line containing a JSON representation of a nested list. Each element is either an integer or another list.

Example:

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

outputFormat

Print the flattened list as space-separated integers on a single line.

Example:

1 2 3 4 5 6 7
## sample
[1, 2, 3]
1 2 3