---
layout: post
title: 977. Squares of a Sorted Array
category: [Leetcode]
description: 
keywords: ['Array', 'Two Pointers', 'Leetcode', 'Easy']
---
### [977. Squares of a Sorted Array](https://leetcode.com/problems/squares-of-a-sorted-array)
#### Tags: 'Array', 'Two Pointers'
<div class="content__u3I1 question-content__JfgR"><div><p>Given an array of integers <code>A</code> sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order.</p>
<p> </p>
<div>
<p><strong>Example 1:</strong></p>
<pre><strong>Input: </strong><span id="example-input-1-1">[-4,-1,0,3,10]</span>
<strong>Output: </strong><span id="example-output-1">[0,1,9,16,100]</span>
</pre>
<div>
<p><strong>Example 2:</strong></p>
<pre><strong>Input: </strong><span id="example-input-2-1">[-7,-3,2,3,11]</span>
<strong>Output: </strong><span id="example-output-2">[4,9,9,49,121]</span>
</pre>
<p> </p>
<p><strong><span>Note:</span></strong></p>
<ol>
<li><code><span>1 &lt;= A.length &lt;= 10000</span></code></li>
<li><code>-10000 &lt;= A[i] &lt;= 10000</code></li>
<li><code>A</code> is sorted in non-decreasing order.</li>
</ol>
</div>
</div></div></div>
### Solution