Skip to content

Commit 3bd424e

Browse files
committed
Added tasks 3512-3519
1 parent 902bbb9 commit 3bd424e

File tree

37 files changed

+1047
-218
lines changed
  • src/main/kotlin
    • g2801_2900
      • s2865_beautiful_towers_i
      • s2874_maximum_value_of_an_ordered_triplet_ii
      • s2896_apply_operations_to_make_two_strings_equal
    • g2901_3000
      • s2908_minimum_sum_of_mountain_triplets_i
      • s2909_minimum_sum_of_mountain_triplets_ii
      • s2911_minimum_changes_to_make_k_semi_palindromes
      • s2926_maximum_balanced_subsequence_sum
      • s2944_minimum_number_of_coins_for_fruits
      • s2954_count_the_number_of_infection_sequences
      • s2958_length_of_longest_subarray_with_at_most_k_frequency
    • g3001_3100
      • s3039_apply_operations_to_make_string_empty
      • s3074_apple_redistribution_into_boxes
      • s3076_shortest_uncommon_substring_in_an_array
      • s3086_minimum_moves_to_pick_k_ones
      • s3092_most_frequent_ids
    • g3101_3200
      • s3121_count_the_number_of_special_characters_ii
      • s3161_block_placement_queries
      • s3196_maximize_total_cost_of_alternating_subarrays
    • g3201_3300
      • s3207_maximum_points_after_enemy_battles
      • s3272_find_the_count_of_good_integers
    • g3301_3400
      • s3327_check_if_dfs_strings_are_palindromes
      • s3372_maximize_the_number_of_target_nodes_after_connecting_trees_i
      • s3394_check_if_grid_can_be_cut_into_sections
    • g3401_3500
      • s3411_maximum_subarray_with_equal_products
      • s3413_maximum_coins_from_k_consecutive_bags
      • s3459_length_of_longest_v_shaped_diagonal_segment
      • s3479_fruits_into_baskets_iii
    • g3501_3600
      • s3508_implement_router
      • s3512_minimum_operations_to_make_array_sum_divisible_by_k
      • s3513_number_of_unique_xor_triplets_i
      • s3514_number_of_unique_xor_triplets_ii
      • s3515_shortest_path_in_a_weighted_tree
      • s3516_find_closest_person
      • s3517_smallest_palindromic_rearrangement_i
      • s3518_smallest_palindromic_rearrangement_ii
      • s3519_count_numbers_with_non_decreasing_digits

37 files changed

+1047
-218
lines changed

README.md

Lines changed: 174 additions & 166 deletions
Large diffs are not rendered by default.

src/main/kotlin/g2801_2900/s2865_beautiful_towers_i/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ class Solution {
7373
var ans = maxHeights[pickId].toLong()
7474
var min = maxHeights[pickId].toLong()
7575
for (i in pickId - 1 downTo 0) {
76-
min = min(min.toDouble(), maxHeights[i].toDouble()).toLong()
76+
min = min(min, maxHeights[i].toLong())
7777
ans += min
7878
}
7979
min = maxHeights[pickId].toLong()
8080
for (i in pickId + 1 until maxHeights.size) {
81-
min = min(min.toDouble(), maxHeights[i].toDouble()).toLong()
81+
min = min(min, maxHeights[i].toLong())
8282
ans += min
8383
}
8484
return ans
@@ -93,7 +93,7 @@ class Solution {
9393
maxHeights[i] >= maxHeights[i + 1]
9494
)
9595
) {
96-
ans = max(ans.toDouble(), `fun`(maxHeights, i).toDouble()).toLong()
96+
ans = max(ans, `fun`(maxHeights, i))
9797
}
9898
}
9999
return ans

src/main/kotlin/g2801_2900/s2874_maximum_value_of_an_ordered_triplet_ii/readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ class Solution {
5151
var tempMax = nums[0]
5252
for (i in 1 until diff.size - 1) {
5353
diff[i] = tempMax - nums[i]
54-
tempMax = max(tempMax.toDouble(), nums[i].toDouble()).toInt()
54+
tempMax = max(tempMax, nums[i])
5555
}
5656
var max = Long.MIN_VALUE
5757
tempMax = nums[nums.size - 1]
5858
for (i in nums.size - 2 downTo 1) {
59-
max = max(max.toDouble(), (tempMax.toLong() * diff[i]).toDouble()).toLong()
60-
tempMax = max(tempMax.toDouble(), nums[i].toDouble()).toInt()
59+
max = max(max, tempMax.toLong() * diff[i])
60+
tempMax = max(tempMax, nums[i])
6161
}
62-
return max(max.toDouble(), 0.0).toLong()
62+
return max(max, 0)
6363
}
6464
}
6565
```

src/main/kotlin/g2801_2900/s2896_apply_operations_to_make_two_strings_equal/readme.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@ class Solution {
6868
}
6969
val dp = IntArray(m)
7070
dp[0] = 0
71-
dp[1] = min(x.toDouble(), (diffs[1] - diffs[0]).toDouble()).toInt()
71+
dp[1] = min(x, diffs[1] - diffs[0])
7272
for (i in 2 until m) {
7373
if ((i and 1) == 1) {
74-
dp[i] = min((dp[i - 1] + x).toDouble(), (dp[i - 2] + diffs[i] - diffs[i - 1]).toDouble())
75-
.toInt()
74+
dp[i] = min(dp[i - 1] + x, dp[i - 2] + diffs[i] - diffs[i - 1])
7675
} else {
77-
dp[i] = min(dp[i - 1].toDouble(), (dp[i - 2] + diffs[i] - diffs[i - 1]).toDouble())
78-
.toInt()
76+
dp[i] = min(dp[i - 1], dp[i - 2] + diffs[i] - diffs[i - 1])
7977
}
8078
}
8179
return dp[m - 1]

src/main/kotlin/g2901_3000/s2908_minimum_sum_of_mountain_triplets_i/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Solution {
6767
for (k in j + 1 until nums.size) {
6868
if (nums[i] < nums[j] && nums[k] < nums[j]) {
6969
val min = nums[i] + nums[k] + nums[j]
70-
output = min(min.toDouble(), output.toDouble()).toInt()
70+
output = min(min, output)
7171
}
7272
}
7373
}

src/main/kotlin/g2901_3000/s2909_minimum_sum_of_mountain_triplets_ii/readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ class Solution {
8484
var ans = Int.MAX_VALUE
8585
for (i in 0 until n) {
8686
if (leftSmallest[i] != -1 && rightSmallest[i] != -1) {
87-
ans = min(ans.toDouble(), (leftSmallest[i] + rightSmallest[i] + nums[i]).toDouble())
88-
.toInt()
87+
ans = min(ans, leftSmallest[i] + rightSmallest[i] + nums[i])
8988
}
9089
}
9190
if (ans == Int.MAX_VALUE) {

src/main/kotlin/g2901_3000/s2911_minimum_changes_to_make_k_semi_palindromes/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class Solution {
7373
}
7474
var min = INF
7575
for (j in (k - 1) * 2 until (i - 1)) {
76-
min = min(min.toDouble(), (calc(j, k - 1) + change(j, i)).toDouble()).toInt()
76+
min = min(min, calc(j, k - 1) + change(j, i))
7777
}
7878
dp[i][k] = min
7979
return min

src/main/kotlin/g2901_3000/s2926_maximum_balanced_subsequence_sum/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class Solution {
130130
var index = index
131131
var result: Long = 0
132132
while (index > 0) {
133-
result = max(tree[index].toDouble(), result.toDouble()).toLong()
133+
result = max(tree[index], result)
134134
index -= lowbit(index)
135135
}
136136
return result

src/main/kotlin/g2901_3000/s2944_minimum_number_of_coins_for_fruits/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class Solution {
7474
if (acquired + 1 < n) {
7575
var min = Int.MAX_VALUE
7676
for (j in acquired + 1 downTo i + 1) {
77-
min = min(min.toDouble(), dp[j].toDouble()).toInt()
77+
min = min(min, dp[j])
7878
}
7979
dp[i] = prices[i] + min
8080
} else {

src/main/kotlin/g2901_3000/s2954_count_the_number_of_infection_sequences/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class Solution {
9292
var res: Long = 1
9393
for (i in 1 until sick.size) {
9494
val group = sick[i] - sick[i - 1] - 1
95-
res = res * modPow(2, max(0.0, (group - 1).toDouble()).toInt(), MOD) % MOD
95+
res = res * modPow(2, max(0, group - 1), MOD) % MOD
9696
res = res * binomCoeff(sick[i] - i, group) % MOD
9797
}
9898
return (res * binomCoeff(n - sick.size, n - sick[sick.size - 1] - 1) % MOD).toInt()

0 commit comments

Comments
 (0)