#C12356. Reverse Nested List
Reverse Nested List
Reverse Nested List
You are given a nested list which may contain integers, floating‐point numbers, strings, or even other lists. Your task is to recursively reverse the order of the elements at each level of the nested list while maintaining its overall structure.
For example, let \(L = [1, [2, 3], 4]\). Then the reversed nested list is \(L' = [4, [3, 2], 1]\).
Note: The reversal should be performed at every level. That is, if an element is a nested list, its elements must also be reversed recursively.
inputFormat
The input is given as a single line containing a valid JSON representation of the nested list. The list may include integers, floating‐point numbers, strings (delimited by double quotes), or other lists.
Example: [1, [2, 3], 4]
outputFormat
Output the reversed nested list in its JSON representation. The structure should be the same as the input, but the order of elements at every level should be reversed.
Example: [4, [3, 2], 1]
[1, 2, 3, 4]
[4, 3, 2, 1]