8000 41th problem · Adtrex/LeetcodeJs@2faa8b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2faa8b8

Browse files
committed
41th problem
1 parent 7dc4c0a commit 2faa8b8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

38. Count and Say.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var countAndSay = function(n) {
2+
if(n == 1){return "1"}
3+
let x = countAndSay(n-1)
4+
let s = ""
5+
let y = x[0]
6+
let c = 1
7+
for(let i = 1 ; i < x.length ;i++){
8+
if(x[i] == y){c++}
9+
else{
10+
s += c + y
11+
y = x[i]
12+
c = 1
13+
}
14+
}
15+
s += c + y
16+
return s
17+
};

41. First Missing Positive.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var firstMissingPositive = function(nums) {
2+
let sortFilterArray = Array.from(new Set(nums)).sort((a,b) => a-b ).filter(num => num > 0)
3+
let pint = 1;
4+
for(let g=0; g<sortFilterArray.length; g++){
5+
if(sortFilterArray[g] != pint){
6+
return pint
7+
}
8+
pint++;
9+
}
10+
return pint
11+
};

0 commit comments

Comments
 (0)
0