#K47717. Flatten and Sort a Nested List

    ID: 28261 Type: Default 1000ms 256MiB

Flatten and Sort a Nested List

Flatten and Sort a Nested List

You are given a nested list of integers. Your task is to flatten this list into a one-dimensional list and then sort the numbers in ascending order. The nested list may contain integers or other nested lists of integers. Implement the solution using a recursive approach to flatten the list.

Mathematically, if ( L ) is a nested list, then the required output is given by ( sort(flat(L)) ), where ( flat(L) ) represents the flattened version of ( L ).

inputFormat

The input is provided on a single line in the form of a JSON formatted nested list of integers. For example: [1, [2, 3], 4].

outputFormat

Output the sorted list of integers as space-separated values on a single line. If the list is empty, output nothing.## sample

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

</p>