Skip to content

Commit d1aacf5

Browse files
committed
Add solution #977
1 parent 6e29028 commit d1aacf5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* 977. Squares of a Sorted Array
3+
* https://leetcode.com/problems/squares-of-a-sorted-array/
4+
* Difficulty: Easy
5+
*
6+
* Given an array of integers A sorted in non-decreasing order,
7+
* return an array of the squares of each number,
8+
* also in sorted non-decreasing order.
9+
*/
10+
11+
/**
12+
* @param {number[]} A
13+
* @return {number[]}
14+
*/
15+
var sortedSquares = function(A) {
16+
return A.map(n => Math.pow(n, 2)).sort((a, b) => a - b);
17+
};

0 commit comments

Comments
 (0)