Given a sorted array of integers, compute the square of each and return them in sorted order.
Explanation: Step-by-step: Given the input [0, 3, 10], we first square each number: 0^2 = 0, 3^2 = 9, 10^2 = 100. Then, we sort the squared values in ascending order: 0, 9, 100.
Explanation: Step-by-step: Given the input [-5, 2, 7], we first square each number: (-5)^2 = 25, 2^2 = 4, 7^2 = 49. Then, we sort the squared values in ascending order: 4, 25, 49.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak