Skip to content

Commit 8adb51b

Browse files
committed
Updated tags
1 parent efb59a8 commit 8adb51b

File tree

8 files changed

+27
-26
lines changed
  • src/main/kotlin/g3501_3600
    • s3556_sum_of_largest_prime_substrings
    • s3557_find_maximum_number_of_non_intersecting_substrings
    • s3558_number_of_ways_to_assign_edge_weights_i
    • s3559_number_of_ways_to_assign_edge_weights_ii
    • s3560_find_minimum_log_transportation_cost
    • s3561_resulting_string_after_adjacent_removals
    • s3562_maximum_profit_from_trading_stocks_with_discounts
    • s3563_lexicographically_smallest_string_after_adjacent_removals

8 files changed

+27
-26
lines changed

src/main/kotlin/g3501_3600/s3556_sum_of_largest_prime_substrings/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package g3501_3600.s3556_sum_of_largest_prime_substrings
22

3-
// #Medium #2025_05_25_Time_21_ms_(100.00%)_Space_42.82_MB_(100.00%)
3+
// #Medium #2025_05_25_Time_25_ms_(100.00%)_Space_43.67_MB_(100.00%)
44

55
class Solution {
66
fun sumOfLargestPrimes(s: String): Long {

src/main/kotlin/g3501_3600/s3557_find_maximum_number_of_non_intersecting_substrings/Solution.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package g3501_3600.s3557_find_maximum_number_of_non_intersecting_substrings
22

3+
// #Medium #2025_05_25_Time_57_ms_(100.00%)_Space_55.58_MB_(100.00%)
4+
35
import java.util.LinkedList
46
import kotlin.math.max
57

6-
// #Medium #2025_05_25_Time_103_ms_(100.00%)_Space_54.87_MB_(100.00%)
7-
88
class Solution {
99
fun maxSubstrings(s: String): Int {
1010
val last: Array<LinkedList<Int>> = Array(26) { LinkedList() }
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
package g3501_3600.s3558_number_of_ways_to_assign_edge_weights_i
22

3-
import java.util.*
3+
// #Medium #2025_05_25_Time_160_ms_(100.00%)_Space_149.66_MB_(100.00%)
44

5-
// #Medium #2025_05_25_Time_118_ms_(100.00%)_Space_122.30_MB_(100.00%)
5+
import java.util.LinkedList
6+
import java.util.Queue
67

78
class Solution {
89
fun assignEdgeWeights(edges: Array<IntArray>): Int {
910
val n = edges.size + 1
10-
val adj: MutableList<MutableList<Int?>?> = ArrayList<MutableList<Int?>?>()
11+
val adj: MutableList<MutableList<Int>> = ArrayList<MutableList<Int>>()
1112
for (i in 0..n) {
12-
adj.add(ArrayList<Int?>())
13+
adj.add(ArrayList<Int>())
1314
}
1415
for (i in edges) {
15-
adj.get(i[0])!!.add(i[1])
16-
adj.get(i[1])!!.add(i[0])
16+
adj[i[0]].add(i[1])
17+
adj[i[1]].add(i[0])
1718
}
1819
val l = IntArray(n + 1)
1920
var max = 0
20-
Arrays.fill(l, -1)
21-
val q: Queue<IntArray?> = LinkedList<IntArray?>()
21+
l.fill(-1)
22+
val q: Queue<IntArray> = LinkedList<IntArray>()
2223
q.offer(intArrayOf(1, 0))
2324
l[1] = 0
2425
while (!q.isEmpty()) {
@@ -28,8 +29,8 @@ class Solution {
2829
max = curr
2930
}
3031
q.remove()
31-
for (next in adj.get(curr)!!) {
32-
if (l[next!!] != -1) {
32+
for (next in adj[curr]) {
33+
if (l[next] != -1) {
3334
continue
3435
}
3536
q.offer(intArrayOf(next, level + 1))
@@ -38,17 +39,17 @@ class Solution {
3839
}
3940
val dp: Array<IntArray> = Array<IntArray>(l[max]) { IntArray(2) }
4041
for (i in dp) {
41-
Arrays.fill(i, -1)
42+
i.fill(-1)
4243
}
4344
return solve(0, 0, dp)
4445
}
4546

4647
private fun solve(ind: Int, odd: Int, dp: Array<IntArray>): Int {
4748
if (ind == dp.size) {
48-
if (odd == 1) {
49-
return 1
49+
return if (odd == 1) {
50+
1
5051
} else {
51-
return 0
52+
0
5253
}
5354
}
5455
if (dp[ind][odd] != -1) {
@@ -60,6 +61,6 @@ class Solution {
6061
}
6162

6263
companion object {
63-
private val MOD = 1e9.toInt() + 7
64+
private const val MOD = 1e9.toInt() + 7
6465
}
6566
}

src/main/kotlin/g3501_3600/s3559_number_of_ways_to_assign_edge_weights_ii/Solution.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package g3501_3600.s3559_number_of_ways_to_assign_edge_weights_ii
22

3+
// #Hard #2025_05_25_Time_197_ms_(100.00%)_Space_158.27_MB_(100.00%)
4+
35
import kotlin.math.ceil
46
import kotlin.math.ln
57

6-
// #Hard #2025_05_25_Time_135_ms_(100.00%)_Space_119.27_MB_(100.00%)
7-
88
class Solution {
99
private var adj: MutableList<MutableList<Int?>?>? = null
1010
private lateinit var level: IntArray

src/main/kotlin/g3501_3600/s3560_find_minimum_log_transportation_cost/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package g3501_3600.s3560_find_minimum_log_transportation_cost
22

3-
// #Easy #2025_05_25_Time_0_ms_(100.00%)_Space_41.10_MB_(56.75%)
3+
// #Easy #2025_05_25_Time_0_ms_(100.00%)_Space_40.46_MB_(100.00%)
44

55
class Solution {
66
fun minCuttingCost(n: Int, m: Int, k: Int): Long {

src/main/kotlin/g3501_3600/s3561_resulting_string_after_adjacent_removals/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package g3501_3600.s3561_resulting_string_after_adjacent_removals
22

3-
// #Medium #2025_05_25_Time_36_ms_(100.00%)_Space_46.14_MB_(64.60%)
3+
// #Medium #2025_05_25_Time_43_ms_(100.00%)_Space_50.83_MB_(68.75%)
44

55
class Solution {
66
fun resultingString(s: String): String {

src/main/kotlin/g3501_3600/s3562_maximum_profit_from_trading_stocks_with_discounts/Solution.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package g3501_3600.s3562_maximum_profit_from_trading_stocks_with_discounts
22

3-
import kotlin.math.max
3+
// #Hard #2025_05_25_Time_40_ms_(100.00%)_Space_49.77_MB_(100.00%)
44

5-
// #Hard #2025_05_25_Time_27_ms_(100.00%)_Space_44.97_MB_(95.42%)
5+
import kotlin.math.max
66

77
class Solution {
88
private lateinit var adj: Array<ArrayList<Int>>

src/main/kotlin/g3501_3600/s3563_lexicographically_smallest_string_after_adjacent_removals/Solution.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package g3501_3600.s3563_lexicographically_smallest_string_after_adjacent_removals
22

3-
import kotlin.math.abs
3+
// #Hard #2025_05_25_Time_186_ms_(100.00%)_Space_49.04_MB_(100.00%)
44

5-
// #Hard #2025_05_25_Time_146_ms_(98.77%)_Space_45.52_MB_(90.12%)
5+
import kotlin.math.abs
66

77
class Solution {
88
private fun checkPair(char1: Char, char2: Char): Boolean {

0 commit comments

Comments
 (0)