File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed
src/main/kotlin/g2901_3000
s2973_find_number_of_coins_to_place_in_tree_nodes
s2983_palindrome_rearrangement_queries Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -47,11 +47,11 @@ class Solution {
47
47
for (ne in next) {
48
48
if (ne != p) {
49
49
val r = dp(g, cost, ne, i)
50
- while (! r.min!! .isEmpty ()) {
50
+ while (r.min!! .isNotEmpty ()) {
51
51
val a = r.min!! .poll()
52
52
pq2.add(a)
53
53
}
54
- while (! r.max!! .isEmpty ()) {
54
+ while (r.max!! .isNotEmpty ()) {
55
55
val a = r.max!! .poll()
56
56
pq.add(a)
57
57
}
@@ -60,11 +60,11 @@ class Solution {
60
60
if (pq.size + pq2.size < 3 ) {
61
61
result[i] = 1
62
62
} else {
63
- val a = if (! pq.isEmpty ()) pq.poll() else 0
64
- val b = if (! pq.isEmpty ()) pq.poll() else 0
65
- val c = if (! pq.isEmpty ()) pq.poll() else 0
66
- val aa = if (! pq2.isEmpty ()) pq2.poll() else 0
67
- val bb = if (! pq2.isEmpty ()) pq2.poll() else 0
63
+ val a = if (pq.isNotEmpty ()) pq.poll() else 0
64
+ val b = if (pq.isNotEmpty ()) pq.poll() else 0
65
+ val c = if (pq.isNotEmpty ()) pq.poll() else 0
66
+ val aa = if (pq2.isNotEmpty ()) pq2.poll() else 0
67
+ val bb = if (pq2.isNotEmpty ()) pq2.poll() else 0
68
68
result[i] = max(0 , (a.toLong() * b * c))
69
69
result[i] = max(result[i], max(0 , (a.toLong() * aa * bb)))
70
70
.toLong()
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ class Solution {
65
65
// in the left half to match the right end of the right interval, this
66
66
// means we do not need the right end of the right interval to go too far
67
67
while (mp.containsKey(s[rptr]) ||
68
- (rptr >= n / 2 && s[rptr] == s[opp(rptr)] && mp.size == 0 )
68
+ (rptr >= n / 2 && s[rptr] == s[opp(rptr)] && mp.isEmpty() )
69
69
) {
70
70
mp.computeIfPresent(s[rptr]) { _: Char? , v: Int -> if (v == 1 ) null else v - 1 }
71
71
rptr--
@@ -79,7 +79,7 @@ class Solution {
79
79
for (i in opp(problemPoint) downTo n / 2 ) {
80
80
mp.compute(s[i]) { _: Char? , v: Int? -> if (v == null ) 1 else v + 1 }
81
81
while (mp.containsKey(s[lptr]) ||
82
- (lptr < n / 2 && s[lptr] == s[opp(lptr)] && mp.size == 0 )
82
+ (lptr < n / 2 && s[lptr] == s[opp(lptr)] && mp.isEmpty() )
83
83
) {
84
84
mp.computeIfPresent(s[lptr]) { _: Char? , v: Int -> if (v == 1 ) null else v - 1 }
85
85
lptr++
You can’t perform that action at this time.
0 commit comments