Skip to content

Commit 848c40c

Browse files
committed
Fixed compile
1 parent fbd898a commit 848c40c

File tree

1 file changed

+7
-11
lines changed
  • src/main/kotlin/g3601_3700/s3620_network_recovery_pathways

1 file changed

+7
-11
lines changed

src/main/kotlin/g3601_3700/s3620_network_recovery_pathways/Solution.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package g3601_3700.s3620_network_recovery_pathways
22

33
// #Hard #Biweekly_Contest_161 #2025_07_22_Time_212_ms_(66.67%)_Space_150.09_MB_(13.33%)
44

5+
import java.util.LinkedList
6+
import java.util.Queue
57
import kotlin.math.max
68

79
class Solution {
8-
private fun topologicalSort(n: Int, g: List<List<Int>>): List<Int> {
10+
private fun topologicalSort(n: Int, g: Array<ArrayList<Int>>): List<Int> {
911
val indeg = IntArray(n)
1012
for (i in 0 until n) {
1113
for (adjNode in g[i]) {
@@ -35,13 +37,13 @@ class Solution {
3537
private fun check(
3638
x: Int,
3739
n: Int,
38-
adj: List<List<IntArray>>,
40+
adj: Array<ArrayList<IntArray>>,
3941
ts: List<Int>,
4042
online: BooleanArray,
4143
k: Long,
4244
): Boolean {
4345
val d = LongArray(n)
44-
Arrays.fill(d, Long.MAX_VALUE)
46+
d.fill(Long.MAX_VALUE)
4547
d[0] = 0
4648
for (u in ts) {
4749
if (d[u] != Long.MAX_VALUE) {
@@ -63,14 +65,8 @@ class Solution {
6365
fun findMaxPathScore(edges: Array<IntArray>, online: BooleanArray, k: Long): Int {
6466
val n = online.size
6567
// Adjacency list for graph with edge weights
66-
val adj = ArrayList<ArrayList<IntArray>>()
67-
for (i in 0 until n) {
68-
adj.add(ArrayList())
69-
}
70-
val g = ArrayList<ArrayList<Int>>()
71-
for (i in 0 until n) {
72-
g.add(ArrayList())
73-
}
68+
val adj = Array<ArrayList<IntArray>>(n) { ArrayList() }
69+
val g = Array<ArrayList<Int>>(n) { ArrayList() }
7470
for (e in edges) {
7571
val u = e[0]
7672
val v = e[1]

0 commit comments

Comments
 (0)