Skip to content

Commit 7dc4cd9

Browse files
committed
Improved 3161
1 parent 5a97bac commit 7dc4cd9

File tree

1 file changed

+6
-1
lines changed
  • src/main/java/g3101_3200/s3161_block_placement_queries

1 file changed

+6
-1
lines changed

src/main/java/g3101_3200/s3161_block_placement_queries/Solution.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public List<Boolean> getResults(int[][] queries) {
2424
UnionFind left = new UnionFind(max + 1);
2525
UnionFind right = new UnionFind(max + 1);
2626
BIT bit = new BIT(max);
27+
initializePositions(size, pos, bit, left, right, max);
28+
return List.of(getBooleans(queries, m, size, left, right, bit));
29+
}
30+
31+
private void initializePositions(
32+
int size, int[] pos, BIT bit, UnionFind left, UnionFind right, int max) {
2733
for (int i = 1; i < size; i++) {
2834
int pre = pos[i - 1];
2935
int cur = pos[i];
@@ -37,7 +43,6 @@ public List<Boolean> getResults(int[][] queries) {
3743
left.parent[j] = pos[size - 1];
3844
right.parent[j] = max;
3945
}
40-
return List.of(getBooleans(queries, m, size, left, right, bit));
4146
}
4247

4348
private Boolean[] getBooleans(

0 commit comments

Comments
 (0)