Practice Squares of a Sorted Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.
Source: Squares of a Sorted Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [-4,-1,0,3,10]
Output
[0,1,9,16,100]
# Example 2
Input
nums = [-7,-3,2,3,11]
Output
[4,9,9,49,121]
Constraints
1 <= nums.length <= 10^4
-10^4 <= nums[i] <= 10^4
nums is sorted in non-decreasing order.
Related LeetCode Problems
Practice more problems similar to Squares of a Sorted Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.