Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 413 Bytes

File metadata and controls

20 lines (15 loc) · 413 Bytes

Sorted Squared Array

Difficulty: easy
Category: Arrays


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.

Sample Input

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

Sample Output

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