Q3. Squares of a sorted array #javascriptcoding #codinginterview

preview_player
Показать описание
🌟 Ready for a challenge?
Practice it using the link in the bio! Go give it a go! 🚀

Question 3: Sorted Squared Array
Difficulty: Easy

Time and space complexity:
O(n) time | O(n) space - where n is the length of the input array

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]

Рекомендации по теме
Комментарии
Автор

🌟 Ready for a challenge?
Practice it using the link in the bio! Go give it a go! 🚀

QuickInterviewPrep
visit shbcf.ru