Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6b765d3

Browse files
committedApr 6, 2025·
Improved 3508
1 parent 923b5f6 commit 6b765d3

File tree

1 file changed

+4
-4
lines changed
  • src/main/kotlin/g3501_3600/s3508_implement_router

1 file changed

+4
-4
lines changed
 

‎src/main/kotlin/g3501_3600/s3508_implement_router/Router.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Router(private val size: Int) {
1919
fun addPacket(source: Int, destination: Int, timestamp: Int): Boolean {
2020
if (map.containsKey(destination)) {
2121
var found = false
22-
val list: ArrayList<IntArray> = map.get(destination)!!
22+
val list: ArrayList<IntArray> = map[destination]!!
2323
for (i in list.indices.reversed()) {
2424
if (list[i][1] < timestamp) {
2525
break
@@ -33,7 +33,7 @@ class Router(private val size: Int) {
3333
}
3434
}
3535
if (map.containsKey(destination)) {
36-
val list: ArrayList<IntArray> = map.get(destination)!!
36+
val list: ArrayList<IntArray> = map[destination]!!
3737
list.add(intArrayOf(source, timestamp))
3838
cur++
3939
q.offer(intArrayOf(source, destination, timestamp))
@@ -55,7 +55,7 @@ class Router(private val size: Int) {
5555
return intArrayOf()
5656
}
5757
val temp = q.poll()
58-
val list: ArrayList<IntArray> = map.get(temp[1])!!
58+
val list: ArrayList<IntArray> = map[temp[1]]!!
5959
list.removeAt(0)
6060
if (list.isEmpty()) {
6161
map.remove(temp[1])
@@ -66,7 +66,7 @@ class Router(private val size: Int) {
6666

6767
fun getCount(destination: Int, startTime: Int, endTime: Int): Int {
6868
if (map.containsKey(destination)) {
69-
val list: ArrayList<IntArray> = map.get(destination)!!
69+
val list: ArrayList<IntArray> = map[destination]!!
7070
var lower = -1
7171
var higher = -1
7272
for (i in list.indices) {

0 commit comments

Comments
 (0)
Please sign in to comment.