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

Commitaa9f09f

Browse files
refactor 40
1 parentf533be9 commitaa9f09f

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed
Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
11
packagecom.fishercoder;
22

33
importcom.fishercoder.solutions._40;
4-
importjava.util.ArrayList;
4+
55
importjava.util.Arrays;
66
importjava.util.List;
7+
78
importorg.junit.BeforeClass;
89
importorg.junit.Test;
910

1011
importstaticorg.junit.Assert.assertEquals;
1112

1213
publicclass_40Test {
13-
privatestatic_40.Solution1solution1;
14-
privatestaticint[]candidates;
15-
privatestaticList<List<Integer>>expected;
16-
17-
@BeforeClass
18-
publicstaticvoidsetup() {
19-
solution1 =new_40.Solution1();
20-
}
21-
22-
@Test
23-
publicvoidtest1() {
24-
candidates =newint[] {10,1,2,7,6,1,5};
25-
expected =newArrayList<>();
26-
expected.add(Arrays.asList(1,1,6));
27-
expected.add(Arrays.asList(1,2,5));
28-
expected.add(Arrays.asList(1,7));
29-
expected.add(Arrays.asList(2,6));
30-
assertEquals(expected,solution1.combinationSum2(candidates,8));
31-
}
14+
privatestatic_40.Solution1solution1;
15+
privatestaticint[]candidates;
16+
privatestaticinttarget;
17+
privatestaticList<List<Integer>>expected;
18+
19+
@BeforeClass
20+
publicstaticvoidsetup() {
21+
solution1 =new_40.Solution1();
22+
}
23+
24+
@Test
25+
publicvoidtest1() {
26+
candidates =newint[]{10,1,2,7,6,1,5};
27+
expected =Arrays.asList((Arrays.asList(1,1,6)),Arrays.asList(1,2,5),Arrays.asList(1,7),Arrays.asList(2,6));
28+
target =8;
29+
assertEquals(expected,solution1.combinationSum2(candidates,target));
30+
}
31+
32+
@Test
33+
publicvoidtest2() {
34+
candidates =newint[]{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
35+
expected =Arrays.asList(Arrays.asList(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1));
36+
target =30;
37+
assertEquals(expected,solution1.combinationSum2(candidates,target));
38+
}
3239
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp