Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a434a3d

Browse files
Merge pull request #29 from deadem/find-2nd-max-tests
add find-2nd-max tests
2 parents 15cf252 + aa7ac4c commit a434a3d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

‎src/_Problems_/find-2nd-max/index.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ function findSecondMax(arr) {
2020
}
2121
return max2;
2222
}
23+
24+
module.exports = {
25+
findSecondMax,
26+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const { findSecondMax } = require('.');
2+
3+
describe('FindSecondMax', () => {
4+
it('Should return 6', () => {
5+
expect(findSecondMax([9, 2, 3, 6])).toEqual(6);
6+
});
7+
8+
it('Should return -1', () => {
9+
expect(findSecondMax([0, -1, -2, 0])).toEqual(-1);
10+
});
11+
12+
it('Should return 0', () => {
13+
expect(findSecondMax([-2, -1, 0, 1])).toEqual(0);
14+
});
15+
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /