Sobes.tech
Junior — Middle+

Squaring a sorted array in one pass

livecode

Task condition

Given an array of integers sorted in ascending order. The task is to produce an array where each element is replaced by its square, and the resulting array should also remain sorted in ascending order. The solution must be performed in a single pass through the original array.