Skip to content

Commit 59ee591

Browse files
committed
Runtime: 83 ms (Top 65.37%) | Memory: 43.7 MB (Top 52.05%)
1 parent f0f1ca5 commit 59ee591

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
// Runtime: 83 ms (Top 65.37%) | Memory: 43.7 MB (Top 52.05%)
2+
13
var arraySign = function(nums) {
2-
// use filter to find total negative numbers in the array
4+
// use filter to find total negative numbers in the array
35
let negativeCount = nums.filter(n => n<0).length;
4-
5-
// check if the nums array has zero. If it does, then return 0
6+
7+
// check if the nums array has zero. If it does, then return 0
68
if(nums.includes(0)) return 0;
7-
8-
// If negativeCount variable is even answer is 1 else -1
9+
10+
// If negativeCount variable is even answer is 1 else -1
911
return negativeCount % 2 === 0 ? 1 : -1
10-
};
12+
};

0 commit comments

Comments
 (0)