#C13659. Flatten and Sort a Nested List of Integers

    ID: 43221 Type: Default 1000ms 256MiB

Flatten and Sort a Nested List of Integers

Flatten and Sort a Nested List of Integers

You are given a nested list of integers. Your task is to flatten the list, i.e., transform it into a one-dimensional list containing all the integers from the nested structure, and then sort the list in non-decreasing order.

The nested list can be arbitrarily deep. For instance, the nested input [3, [1, 2], [4, [5]]] should yield the output [1, 2, 3, 4, 5].

Note: All formulas or mathematical expressions should be formatted in \(\LaTeX\) if used. However, for this problem, only basic operations and recursion are required.

inputFormat

The input is provided on a single line in JSON format representing the nested list of integers. The list may contain other nested lists. For example:

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

outputFormat

Output the flattened and sorted list of integers as space-separated values in a single line. For example, for the input above, the correct output would be:

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

</p>