...

/

Solution: Squares of a Sorted Array

Solution: Squares of a Sorted Array

Let’s solve the Squares of a Sorted Array problem using the Two Pointers pattern.

Statement

You are given an integer array, nums, sorted in non-decreasing order. Your task is to return a new array containing the squares of each number, also sorted in non-decreasing order.

Constraints:

  • 11 \leq nums.length 103\leq 10^3 ...