Back to course home

0% completed

Squaring a Sorted Array (easy)

### Problem Statement

Given a sorted array, create a new array containing squares of all the numbers of the input array in the sorted order.

**Example 1**:

```
Input: [-2, -1, 0, 2, 3]
Output: [0, 1, 4, 4, 9]
```

**Example 2**:

```
Input: [-3, -1, 0, 1, 2]
Output: [0, 1, 1, 4, 9]
```

**Constraints:**

`1 <= arr.length <= 104`

`-104 <= arr[i] <= 104`

`arr`

is sorted in non-decreasing order.

## Try it yourself

Try solving this question here:

Python3

Python3

. . .

Mark as Completed