Coding Interview Prep: The Sorted Squared Array problem.

Moeedlodhi
1 min readNov 13, 2023

Let’s get on with this one.

Create a function that accepts a non-empty array of integers sorted in ascending order. The function should produce a new array, of equal length, containing the squares of the original integers while maintaining ascending order.

Sample Input:

[1, 2, 3, 5, 6, 8, 9]

Sample Output:

[1, 4, 25, 36, 64, 81]

Seems like a pretty simple problem. We are given an array that has been sorted…

--

--