Skip to content

Commit d3a8027

Browse files
BarklimBarklim
authored andcommitted
Create 1822.js
1 parent 0e670d5 commit d3a8027

File tree

1 file changed

+29
-0
lines changed
  • example/ProgrammingSkills/0.Basic

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number}
4+
*/
5+
var arraySign = function(nums) {
6+
7+
};
8+
9+
const example1 = arraySign([-1,-2,-3,-4,3,2,1]); // 1
10+
const example2 = arraySign([1,5,0,2,-3]); // 0
11+
const example3 = arraySign([-1,1,-1,1,-1]); // -1
12+
13+
console.log(example1);
14+
console.log(example2);
15+
console.log(example3);
16+
17+
// var arraySign = function(nums) {
18+
// let minusCount = 0;
19+
// for (const number of nums) {
20+
// if (number === 0) {
21+
// return 0
22+
// }
23+
24+
// if (number < 0) {
25+
// minusCount += 1
26+
// }
27+
// }
28+
// return minusCount % 2 === 0 ? 1 : -1
29+
// };

0 commit comments

Comments
 (0)