File tree 1 file changed +6
-6
lines changed
src/main/kotlin/g3201_3300/s3283_maximum_number_of_moves_to_kill_all_pawns
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 1
1
package g3201_3300.s3283_maximum_number_of_moves_to_kill_all_pawns
2
2
3
3
// #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%)
5
5
6
6
import kotlin.math.max
7
7
import kotlin.math.min
@@ -23,20 +23,20 @@ class Solution {
23
23
var count = n - i
24
24
val visited = Array <BooleanArray >(50 ) { BooleanArray (50 ) }
25
25
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 ]))
28
28
var steps = 1
29
- while (! que.isEmpty () && count > 0 ) {
29
+ while (que.isNotEmpty () && count > 0 ) {
30
30
var size = que.size
31
31
while (size-- > 0 ) {
32
- val cur = que.poll ()
32
+ val cur = que.removeFirst ()
33
33
val x = cur[0 ]
34
34
val y = cur[1 ]
35
35
for (d in DIRECTIONS ) {
36
36
val nx = x + d[0 ]
37
37
val ny = y + d[1 ]
38
38
if (0 <= nx && nx < 50 && 0 <= ny && ny < 50 && ! visited[nx][ny]) {
39
- que.offer (intArrayOf(nx, ny))
39
+ que.add (intArrayOf(nx, ny))
40
40
visited[nx][ny] = true
41
41
val j = pos[nx][ny]
42
42
if (j > i) {
You can’t perform that action at this time.
0 commit comments