Skip to content

Commit 5af5b54

Browse files
committed
add FrogRiverOne
1 parent b91fc3c commit 5af5b54

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- [TapeEquilibrium](#s_3_tape_equilibrium)
1818
- [Lesson 4 - Counting Elements](#s_4)
1919
- [PermCheck](#s_4_perm_check)
20+
- [FrogRiverOne](#s_4_frog_river_one)
2021
- [Licence](#licence)
2122

2223
<a name="installation"></a>
@@ -143,6 +144,18 @@ https://github.com/talgat-ruby/codility-lessons-javascript/blob/master/lesson4_c
143144

144145
https://app.codility.com/demo/results/trainingCNTYP4-RDE/
145146

147+
<a name="s_4_frog_river_one"></a>
148+
149+
#### FrogRiverOne
150+
151+
##### File
152+
153+
https://github.com/talgat-ruby/codility-lessons-javascript/blob/master/lesson4_counting_elements/FrogRiverOne.js
154+
155+
##### Link to Report
156+
157+
https://app.codility.com/demo/results/training5PWD9F-PE9/
158+
146159
<a name="licence"></a>
147160

148161
## License
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function solution(X, A) {
2+
const set = new Set();
3+
for (let i = 0; i < A.length; i++) {
4+
set.add(A[i]);
5+
if (set.size === X) {
6+
return i;
7+
}
8+
}
9+
return -1;
10+
}
11+
12+
module.exports = solution;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const solution = require("./FrogRiverOne");
2+
3+
describe("test FrogRiverOne", () => {
4+
test("(5, [1, 3, 1, 4, 2, 3, 5, 4]) -> 6", () => {
5+
expect(solution(5, [1, 3, 1, 4, 2, 3, 5, 4])).toBe(6);
6+
});
7+
});

0 commit comments

Comments
 (0)