#K36302. Square and Sort
Square and Sort
Square and Sort
Given a list of integers, your task is to square each element and then output the squared numbers in non-decreasing order. That is, if you are given a list (a_1, a_2, \ldots, a_n), you should compute (a_i^2) for every valid index (i) and output the sequence sorted in increasing order. This problem tests basic array manipulation and sorting techniques.
inputFormat
The input is read from standard input (stdin).
The first line contains an integer (N) indicating the number of elements in the list. If (N > 0), the second line contains (N) space-separated integers. If (N = 0), no further input follows.
outputFormat
Output the squared numbers sorted in non-decreasing order on a single line, separated by spaces. If the list is empty (i.e. (N = 0)), output an empty line.## sample
5
-7 -3 2 3 11
4 9 9 49 121