File tree 4 files changed +14
-9
lines changed
s3507_minimum_pair_removal_to_sort_array_i
s3509_maximum_product_of_subsequences_with_an_alternating_sum_equal_to_k
s3510_minimum_pair_removal_to_sort_array_ii
4 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,16 @@ public int minimumPairRemoval(int[] nums) {
19
19
// Merge the pair at index
20
20
int [] newNums = new int [nums .length - 1 ];
21
21
int j = 0 ;
22
- for (int i = 0 ; i < nums .length ; i ++) {
22
+ int i = 0 ;
23
+ while (i < nums .length ) {
23
24
if (i == index ) {
24
25
newNums [j ++] = nums [i ] + nums [i + 1 ];
25
26
// Skip the next one since it's merged
26
27
i ++;
27
28
} else {
28
29
newNums [j ++] = nums [i ];
29
30
}
31
+ i ++;
30
32
}
31
33
nums = newNums ;
32
34
operations ++;
Original file line number Diff line number Diff line change 7
7
import java .util .LinkedList ;
8
8
import java .util .Queue ;
9
9
10
+ @ SuppressWarnings ("java:S135" )
10
11
public class Router {
11
12
private final int size ;
12
13
private int cur ;
Original file line number Diff line number Diff line change 6
6
import java .util .HashMap ;
7
7
import java .util .Map ;
8
8
9
+ @ SuppressWarnings ("java:S6541" )
9
10
public class Solution {
10
11
static class StateKey {
11
12
int prod ;
Original file line number Diff line number Diff line change 6
6
import java .util .Arrays ;
7
7
import java .util .List ;
8
8
9
+ @ SuppressWarnings ("java:S127" )
9
10
public class Solution {
10
11
public int minimumPairRemoval (int [] nums ) {
11
12
int n = nums .length ;
@@ -64,16 +65,16 @@ public int minimumPairRemoval(int[] nums) {
64
65
}
65
66
66
67
public static class MinHeapL {
67
- public long [] hi ;
68
- public long [] lo ;
69
- public int [] map ;
70
- public int [] imap ;
71
- public int n ;
72
- public int pos ;
73
- public static final long INF = Long .MAX_VALUE ;
68
+ static final long INF = Long .MAX_VALUE ;
69
+
70
+ long [] hi ;
71
+ long [] lo ;
72
+ int [] map ;
73
+ int [] imap ;
74
+ int n ;
75
+ int pos ;
74
76
75
77
public MinHeapL (int m ) {
76
- // ヒープ配列のサイズは内部実装に合わせて決定
77
78
n = Integer .highestOneBit ((m + 1 ) << 1 );
78
79
hi = new long [n ];
79
80
lo = new long [n ];
You can’t perform that action at this time.
0 commit comments