Solution: Squares of a Sorted Array
Explore how to use the two pointers approach to solve the problem of squaring a sorted array and returning a new sorted array of these squares. This lesson helps you understand and implement an optimal linear time solution by comparing absolute values from both ends of the array and filling the result from back to front.
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:
...