File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
src/main/kotlin/g3201_3300/s3283_maximum_number_of_moves_to_kill_all_pawns Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 11package g3201_3300.s3283_maximum_number_of_moves_to_kill_all_pawns
22
33// #Hard #Array #Math #Breadth_First_Search #Bit_Manipulation #Bitmask #Game_Theory
4- // #2025_03_22_Time_119_ms_ (100.00%)_Space_66.82_MB_ (100.00%)
4+ // #2025_03_22_Time_147_ms_ (100.00%)_Space_67.70_MB_ (100.00%)
55
66import kotlin.math.max
77import kotlin.math.min
@@ -23,20 +23,20 @@ class Solution {
2323 var count = n - i
2424 val visited = Array <BooleanArray >(50 ) { BooleanArray (50 ) }
2525 visited[positions[i][0 ]][positions[i][1 ]] = true
26- val que: java.util. Queue <IntArray > = java.util. ArrayDeque < IntArray > ()
27- que.offer (intArrayOf(positions[i][0 ], positions[i][1 ]))
26+ val que: ArrayDeque <IntArray > = ArrayDeque ()
27+ que.add (intArrayOf(positions[i][0 ], positions[i][1 ]))
2828 var steps = 1
29- while (! que.isEmpty () && count > 0 ) {
29+ while (que.isNotEmpty () && count > 0 ) {
3030 var size = que.size
3131 while (size-- > 0 ) {
32- val cur = que.poll ()
32+ val cur = que.removeFirst ()
3333 val x = cur[0 ]
3434 val y = cur[1 ]
3535 for (d in DIRECTIONS ) {
3636 val nx = x + d[0 ]
3737 val ny = y + d[1 ]
3838 if (0 <= nx && nx < 50 && 0 <= ny && ny < 50 && ! visited[nx][ny]) {
39- que.offer (intArrayOf(nx, ny))
39+ que.add (intArrayOf(nx, ny))
4040 visited[nx][ny] = true
4141 val j = pos[nx][ny]
4242 if (j > i) {
You can’t perform that action at this time.
0 commit comments