CodeMentor.
Ask AIProblemsLearnC++TCSCore CSHRProgress
0Lv 1
ProblemsTwo Pointers

Squares of a Sorted Array

Easy
LeetCode
6/7
EasyTwo PointersLeetCode #977

Squares of Sorted Array

Negatives square large too. Two pointers from ends; fill result from back.

Examples

Example 1

Input

5
-4 -1 0 3 10

Output

0 1 9 16 100
Example 2

Input

5
-7 -3 2 3 11

Output

4 9 9 49 121

Stuck? Take a nudge

C++17Autosaves