Skip to content

Commit 4c96171

Browse files
authored
Improved tasks 3349-3357
1 parent 8878878 commit 4c96171

File tree

6 files changed

+9
-9
lines changed
  • src/main/kotlin/g3301_3400
    • s3349_adjacent_increasing_subarrays_detection_i
    • s3350_adjacent_increasing_subarrays_detection_ii
    • s3352_count_k_reducible_numbers_less_than_n
    • s3354_make_array_elements_equal_to_zero
    • s3355_zero_array_transformation_i
    • s3357_minimize_the_maximum_adjacent_element_difference

6 files changed

+9
-9
lines changed

src/main/kotlin/g3301_3400/s3349_adjacent_increasing_subarrays_detection_i/Solution.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Solution {
88
if (l < k * 2) {
99
return false
1010
}
11-
for (i in 0.rangeUntil(l - 2 * k + 1)) {
11+
for (i in 0..<l - 2 * k + 1) {
1212
if (check(i, k, nums) && check(i + k, k, nums)) {
1313
return true
1414
}
@@ -17,7 +17,7 @@ class Solution {
1717
}
1818

1919
private fun check(p: Int, k: Int, nums: List<Int>): Boolean {
20-
for (i in p.rangeUntil(p + k - 1)) {
20+
for (i in p..<p + k - 1) {
2121
if (nums[i] >= nums[i + 1]) {
2222
return false
2323
}

src/main/kotlin/g3301_3400/s3350_adjacent_increasing_subarrays_detection_ii/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Solution {
99
fun maxIncreasingSubarrays(nums: List<Int>): Int {
1010
val n = nums.size
1111
val a = IntArray(n)
12-
for (i in 0.rangeUntil(n)) {
12+
for (i in 0..<n) {
1313
a[i] = nums[i]
1414
}
1515
var ans = 1

src/main/kotlin/g3301_3400/s3352_count_k_reducible_numbers_less_than_n/Solution.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ class Solution {
77
fun countKReducibleNumbers(s: String, k: Int): Int {
88
val n = s.length
99
val reducible = IntArray(n + 1)
10-
for (i in 2.rangeUntil(reducible.size)) {
10+
for (i in 2..<reducible.size) {
1111
reducible[i] = 1 + reducible[Integer.bitCount(i)]
1212
}
1313
val dp = LongArray(n + 1)
1414
var curr = 0
15-
for (i in 0.rangeUntil(n)) {
15+
for (i in 0..<n) {
1616
for (j in i - 1 downTo 0) {
1717
dp[j + 1] += dp[j]
1818
dp[j + 1] %= MOD.toLong()

src/main/kotlin/g3301_3400/s3354_make_array_elements_equal_to_zero/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Solution {
1111
var result = 0
1212
leftSum[0] = 0
1313
rightSum[nums.size - 1] = 0
14-
for (i in 1.rangeUntil(nums.size)) {
14+
for (i in 1..<nums.size) {
1515
leftSum[i] = leftSum[i - 1] + nums[i - 1]
1616
}
1717
for (j in nums.size - 2 downTo 0) {

src/main/kotlin/g3301_3400/s3355_zero_array_transformation_i/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Solution {
2121
diff[high + 1] += 1
2222
}
2323
}
24-
for (i in 0.rangeUntil(n)) {
24+
for (i in 0..<n) {
2525
if (i > 0) {
2626
diff[i] += diff[i - 1]
2727
}

src/main/kotlin/g3301_3400/s3357_minimize_the_maximum_adjacent_element_difference/Solution.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Solution {
1212
var maxAdj = 0
1313
var mina = Int.Companion.MAX_VALUE
1414
var maxb = Int.Companion.MIN_VALUE
15-
for (i in 0.rangeUntil(n - 1)) {
15+
for (i in 0..<n - 1) {
1616
val a = nums[i]
1717
val b = nums[i + 1]
1818
if (a > 0 && b > 0) {
@@ -23,7 +23,7 @@ class Solution {
2323
}
2424
}
2525
var res = 0
26-
for (i in 0.rangeUntil(n)) {
26+
for (i in 0..<n) {
2727
if ((i > 0 && nums[i - 1] == -1) || nums[i] > 0) {
2828
continue
2929
}

0 commit comments

Comments
 (0)