Sobes.tech
Junior — Middle+

Squares of a sorted array

livecode

Task condition

Given an array of integers arr of length 'length', sorted in ascending order. Implement a function that creates a new array containing the squares of all elements of the original array, while maintaining the ascending order in the resulting sequence.

Example: [-3, 2, 4] → [4, 9, 16]