Write a function that takes in a non-empty array of integers that are sorted in ascending order and returns a new array of the same length with the squares of the original integers also sorted in ascending order.
Print the output like this: INPUT [1, 2, 3..] > OUTPUT [1, 4, 9..]
array = [1, 2, 3, 5, 6, 8, 9]
[1, 4, 9, 25, 36, 64, 81]
{
"array": [1, 2, 3, 5, 6, 8, 9]
}
[1, 4, 9, 25, 36, 64, 81]
{
"array": [-2, -1]
}
[1, 4]
"array": [-10, -5, 0, 5, 10]
[0, 25, 25, 100, 100]