#C11073. Sorted Squares
Sorted Squares
Sorted Squares
You are given a list of integers. Your task is to compute the square of each integer and then sort these squares in non-decreasing order. In other words, for a given list \(nums\), you need to output a list \(squares\) such that \(squares[i] = nums[i]^2\) and \(squares\) is sorted in increasing order.
The input is provided via standard input and the output must be printed to standard output.
Example:
Input: 5 -4 -2 0 1 3</p>Output: 0 1 4 9 16
inputFormat
The first line contains an integer \(n\), the number of elements in the list. The second line contains \(n\) space-separated integers representing the elements of the list \(nums\).
outputFormat
Output a single line containing \(n\) integers which are the squares of the input integers sorted in non-decreasing order. The numbers should be separated by a single space.
## sample5
-4 -2 0 1 3
0 1 4 9 16