Solution: Squares of a Sorted Array
Explore how to use the two-pointer pattern to square elements from a sorted array and return them in sorted order. This lesson helps you implement an optimal O(n) time and O(1) extra space solution by comparing absolute values from both ends of the array and filling a result array efficiently.
We'll cover the following...
We'll cover the following...
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:
...