Problem · Array
Squares of a Sorted Array
Learn this problemProblem statement
Given an integer array nums sorted in nondecreasing order, square every value and return the resulting values in nondecreasing order.
Function
sortedSquares(nums: int[]) → int[]Examples
Example 1
nums = [-4,-1,0,3,10]return = [0,1,9,16,100]Example 2
nums = [-7,-3,2,3,11]return = [4,9,9,49,121]