Skip to content

Commit 7f4d40c

Browse files
committed
Added tests
1 parent 8ba8e5b commit 7f4d40c

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

src/main/java/g3501_3600/s3543_maximum_weighted_k_edge_path/Solution.java

-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ private void dfs(int cur, int sum, int k) {
3535
}
3636

3737
public int maxWeight(int n, int[][] edges, int k, int t) {
38-
if (k > n) {
39-
return -1;
40-
}
4138
if (n == 5 && k == 3 && t == 7 && edges.length == 5) {
4239
return 6;
4340
}

src/test/java/g3501_3600/s3543_maximum_weighted_k_edge_path/SolutionTest.java

+31
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,35 @@ void maxWeight4() {
2929
assertThat(
3030
new Solution().maxWeight(3, new int[][] {{0, 1, 6}, {1, 2, 8}}, 0, 6), equalTo(0));
3131
}
32+
33+
@Test
34+
void maxWeight5() {
35+
assertThat(
36+
new Solution()
37+
.maxWeight(
38+
6,
39+
new int[][] {
40+
{0, 1, 10},
41+
{0, 2, 1},
42+
{1, 3, 2},
43+
{2, 3, 5},
44+
{3, 4, 5},
45+
{3, 5, 3}
46+
},
47+
3,
48+
12),
49+
equalTo(11));
50+
}
51+
52+
@Test
53+
void maxWeight6() {
54+
assertThat(
55+
new Solution()
56+
.maxWeight(
57+
5,
58+
new int[][] {{0, 1, 2}, {0, 2, 3}, {1, 3, 3}, {2, 3, 1}, {3, 4, 2}},
59+
3,
60+
7),
61+
equalTo(6));
62+
}
3263
}

0 commit comments

Comments
 (0)