Code RoomSorted squares of array
EasyPrep Room Coding #892

Sorted squares of array

CodingAlgorithms & data structuresEntry–Mid~15 min

Given an integer array nums sorted in non-decreasing order, return a new array of the squares of each number, also sorted non-decreasing, in O(n) time without sorting at the end. Constraints: 1 <= len(nums) <= 10^4, -10^4 <= nums[i] <= 10^4.

Implement
sorted_squares(nums: list[int]) → list[int]
Examples
in[[-4,-1,0,3,10]]out[0,1,9,16,100]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 15 min
InputExpectedGot
[[-4,-1,0,3,10]][0,1,9,16,100]not run yetsample