Skip to content

Commit 9c6cd83

Browse files
committed
day64
1 parent 8b90c4f commit 9c6cd83

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Day64/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number[]}
4+
*/
5+
var sortedSquares = function (nums) {
6+
7+
let l = 0;
8+
let r = nums.length - 1;
9+
10+
let result = [];
11+
12+
while (l <= r) {
13+
let num1 = Math.pow(nums[l], 2);
14+
let num2 = Math.pow(nums[r], 2);
15+
16+
if (num1 > num2) {
17+
result.push(num1);
18+
l++
19+
} else {
20+
result.push(num2);
21+
r--;
22+
}
23+
}
24+
25+
return result.reverse()
26+
};

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,6 @@ If you are loving solving problems in leetcode, please contact me to enjoy it to
143143

144144
|Day 62| [312. Burst Balloons](https://leetcode.com/problems/burst-balloons/) | [javascript]()|[:memo:](https://leetcode.com/problems/burst-balloons/)|Hard|
145145

146-
|Day 63| [131. Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning/) | [javascript]()|[:memo:](https://leetcode.com/problems/palindrome-partitioning/)|Medium|
146+
|Day 63| [131. Palindrome Partitioning](https://leetcode.com/problems/palindrome-partitioning/) | [javascript]()|[:memo:](https://leetcode.com/problems/palindrome-partitioning/)|Medium|
147+
148+
|Day 64| [131. Palindrome Partitioning](https://leetcode.com/problems/squares-of-a-sorted-array/) | [javascript]()|[:memo:](https://leetcode.com/problems/squares-of-a-sorted-array/)|Easy|

0 commit comments

Comments
 (0)