#K5651. Decompress, Sort, and Format Integers
Decompress, Sort, and Format Integers
Decompress, Sort, and Format Integers
You are given a string s representing a compressed list of integers. The string may contain integers separated by commas and nested sublists delimited by square brackets. Your task is to decompress the string into a list of integers, sort the list in non-decreasing order, and then output the sorted integers as a space-separated string.
More formally, if the decompressed list of integers is \(a_1,a_2,\dots,a_n\), you must output a string of the form:
[ \texttt{a_1 a_2 \dots a_n} ]
For example, given the input [2,3,[1,5],[4,[7,6],8]]
, the decompressed list is \([2,3,1,5,4,7,6,8]\). After sorting the list, you obtain \([1,2,3,4,5,6,7,8]\), and the required output is 1 2 3 4 5 6 7 8
.
inputFormat
The input is provided via stdin as a single line containing the compressed string s. The string consists of integers, commas, and square brackets only.
outputFormat
Output to stdout a single line containing the sorted integers separated by a single space.
## sample[2,3,[1,5],[4,[7,6],8]]
1 2 3 4 5 6 7 8