Skip to content

Commit df6cf78

Browse files
committed
add MissingInteger
1 parent aa844a2 commit df6cf78

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- [PermCheck](#s_4_perm_check)
2020
- [FrogRiverOne](#s_4_frog_river_one)
2121
- [MaxCounters](#s_4_max_counters)
22+
- [MissingInteger](#s_4_max_counters)
2223
- [Licence](#licence)
2324

2425
<a name="installation"></a>
@@ -169,6 +170,18 @@ https://github.com/talgat-ruby/codility-lessons-javascript/blob/master/lesson4_c
169170

170171
https://app.codility.com/demo/results/training5T6ZHR-8ZK/
171172

173+
<a name="s_4_missing_integer"></a>
174+
175+
#### MissingInteger
176+
177+
##### File
178+
179+
https://github.com/talgat-ruby/codility-lessons-javascript/blob/master/lesson4_counting_elements/MissingInteger.js
180+
181+
##### Link to Report
182+
183+
https://app.codility.com/demo/results/training86F8QY-JHX/
184+
172185
<a name="licence"></a>
173186

174187
## License
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function solution(A) {
2+
const set = new Set(A);
3+
4+
let i = 1;
5+
while (set.has(i)) {
6+
i++;
7+
}
8+
return i;
9+
}
10+
11+
module.exports = solution;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const solution = require("./MissingInteger");
2+
3+
describe("test MissingInteger", () => {
4+
test("[1, 3, 6, 4, 1, 2] -> 5", () => {
5+
expect(solution([1, 3, 6, 4, 1, 2])).toBe(5);
6+
});
7+
test("[1, 2, 3] -> 4", () => {
8+
expect(solution([1, 2, 3])).toBe(4);
9+
});
10+
test("[−1, −3] -> 1", () => {
11+
expect(solution([-1, -3])).toBe(1);
12+
});
13+
});

0 commit comments

Comments
 (0)