Given a non-decreasing array, return a non-decreasing array of the squares of the elements.
Example 1
Input: nums = [-5, -3, 1, 4]
Output: [1, 9, 16, 25]
Explanation: Square each element to get [25,9,1,16], after sorting — [1,9,16,25].
Output: [1, 9, 16, 25]
Explanation: Square each element to get [25,9,1,16], after sorting — [1,9,16,25].
Example 2
Input: nums = [-2, 0, 2]
Output: [0, 4, 4]
Explanation: Square each element: [-2,0,2] -> [4,0,4], then sort: [0,4,4].
Output: [0, 4, 4]
Explanation: Square each element: [-2,0,2] -> [4,0,4], then sort: [0,4,4].
Example 3
Input: nums = [-3, -1, 0]
Output: [0, 1, 9]
Explanation: Square each element: [-3,-1,0] -> [9,1,0], after sorting we get [0,1,9].
Output: [0, 1, 9]
Explanation: Square each element: [-3,-1,0] -> [9,1,0], after sorting we get [0,1,9].