Skip to content

Commit b3919a0

Browse files
committed
Added test
1 parent ba3ebe1 commit b3919a0

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/main/java/g3401_3500/s3470_permutations_iv/Solution.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public int[] permute(int n, long k) {
8484
return new int[0];
8585
}
8686
for (int z = 1; z < n; z++) {
87-
boolean taken = false;
8887
for (int j = 1; j <= n; j++) {
8988
if (!used[j] && ((j & 1) != last)) {
9089
int odd2 = odd;
@@ -106,14 +105,10 @@ public int[] permute(int n, long k) {
106105
odd = odd2;
107106
even = even2;
108107
last = cp;
109-
taken = true;
110108
break;
111109
}
112110
}
113111
}
114-
if (!taken) {
115-
return new int[0];
116-
}
117112
}
118113
return ans.stream().mapToInt(i -> i).toArray();
119114
}

src/test/java/g3401_3500/s3470_permutations_iv/SolutionTest.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,28 @@
88
class SolutionTest {
99
@Test
1010
void permute() {
11-
assertThat(new Solution().permute(4, 6), equalTo(new int[] {3, 4, 1, 2}));
11+
assertThat(new Solution().permute(4, 6L), equalTo(new int[] {3, 4, 1, 2}));
1212
}
1313

1414
@Test
1515
void permute2() {
16-
assertThat(new Solution().permute(3, 2), equalTo(new int[] {3, 2, 1}));
16+
assertThat(new Solution().permute(3, 2L), equalTo(new int[] {3, 2, 1}));
1717
}
1818

1919
@Test
2020
void permute3() {
21-
assertThat(new Solution().permute(2, 3), equalTo(new int[] {}));
21+
assertThat(new Solution().permute(2, 3L), equalTo(new int[] {}));
22+
}
23+
24+
@Test
25+
void permute4() {
26+
assertThat(
27+
new Solution().permute(43, 142570305460935L),
28+
equalTo(
29+
new int[] {
30+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
31+
21, 22, 43, 40, 27, 36, 25, 34, 31, 32, 29, 28, 33, 24, 23, 26, 41, 42,
32+
35, 38, 37, 30, 39
33+
}));
2234
}
2335
}

0 commit comments

Comments
 (0)