Movatterモバイル変換


[0]ホーム

URL:


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

Commit2f77c80

Browse files
add test for 378
1 parentf9feb70 commit2f77c80

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

‎src/main/java/com/fishercoder/solutions/_378.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static class Solution2 {
2828
* end of row util we find the element is less than the mid, the left side element is all less than mid; keep tracking elements
2929
* that less than mid and compare with k, then update the k.
3030
*/
31-
publicintkthSmallestBS(int[][]matrix,intk) {
31+
publicintkthSmallest(int[][]matrix,intk) {
3232
introw =matrix.length -1;
3333
intcol =matrix[0].length -1;
3434
intlo =matrix[0][0];
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
packagecom.fishercoder;
2+
3+
importcom.fishercoder.common.utils.CommonUtils;
4+
importcom.fishercoder.solutions._378;
5+
importorg.junit.BeforeClass;
6+
importorg.junit.Test;
7+
8+
importstaticorg.junit.Assert.assertEquals;
9+
10+
publicclass_378Test {
11+
privatestatic_378.Solution1solution1;
12+
privatestatic_378.Solution2solution2;
13+
privatestaticint[][]matrix;
14+
15+
@BeforeClass
16+
publicstaticvoidsetup() {
17+
solution1 =new_378.Solution1();
18+
solution2 =new_378.Solution2();
19+
}
20+
21+
@Test
22+
publicvoidtest1() {
23+
matrix =newint[][]{
24+
newint[]{-5}
25+
};
26+
assertEquals(-5,solution1.kthSmallest(matrix,1));
27+
assertEquals(-5,solution2.kthSmallest(matrix,1));
28+
}
29+
30+
@Test
31+
publicvoidtest2() {
32+
matrix =CommonUtils.convertLeetCodeIrregularLengths2DArrayInputIntoJavaArray("[1,2],[1,3]");
33+
assertEquals(1,solution1.kthSmallest(matrix,2));
34+
assertEquals(1,solution2.kthSmallest(matrix,2));
35+
}
36+
37+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp