Solution: Squares of a Sorted Array
Understand how to apply the two pointers technique to square elements of a sorted array and produce a sorted result efficiently. This lesson helps you implement an optimized linear time algorithm by comparing absolute values from both ends and filling a result array from right to left.
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:
...