Squares of a Sorted Array
Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.
Squares of a Sorted Array

Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.

Example 1:
Input: [-4,-1,0,3,10]
Output: [0,1,9,16,100]
Input
arr =[-4,-1,0,3,10]

Sort squares of 5 numbers using two pointers

Left
Right
Filled
Input Array (sorted)
L

-4

0

-1

1

0

2

3

3
R

10

4
Result Array (filling from right to left)

_

0

_

1

_

2

_

3

_

4
Variables
No variables to display
DepthFunction Call
Stack empty
0/11