Squares Of A Sorted Array
easy
1. Given an integer array 'nums' sorted in non-decreasing order. 2. Return an array of the squares of each number sorted in non-decreasing order.
Constraints
1. 1 <= nums.length <= 10^4 2. -10^4 <= nums[i] <= 10^4 3. 'nums' is sorted in non-decreasing order.
Format
Input
nums = [-4,-1,0,3,10]
Output
[0,1,9,16,100] Explanation: After squaring, the array becomes [16,1,0,9,100]. After sorting, it becomes [0,1,9,16,100].
Example
Sample Input
9
-6 -2 -1 0 1 4 5 7 9
Sample Output
0 1 1 4 16 25 36 49 81
Question Video