diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 71b5dfa4d..9ccc8fc42 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -52,7 +52,7 @@ jobs: uses: actions/checkout@v4 - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17' diff --git a/build.gradle.kts b/build.gradle.kts index dcbe1fdff..bfe377e39 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - kotlin("jvm") version "1.9.23" + kotlin("jvm") version "2.0.0-RC1" jacoco id("org.sonarqube") version "5.0.0.4638" id("com.diffplug.spotless") version "6.12.0" @@ -14,7 +14,7 @@ repositories { } dependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.23") + implementation("org.jetbrains.kotlin:kotlin-stdlib:2.0.0-RC1") testImplementation("org.junit.jupiter:junit-jupiter:[5.10.2,)") testImplementation("org.hamcrest:hamcrest-core:[2.2,)") testImplementation("org.zapodot:embedded-db-junit-jupiter:[2.1.1,)") @@ -33,7 +33,9 @@ java.sourceCompatibility = JavaVersion.VERSION_11 java.targetCompatibility = JavaVersion.VERSION_11 tasks.withType { - kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString() + compilerOptions { + jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11) + } } publishing { diff --git a/pom-central.xml b/pom-central.xml index d20bd4e5b..5e3ab051a 100644 --- a/pom-central.xml +++ b/pom-central.xml @@ -27,7 +27,7 @@ https://github.com/javadev/LeetCode-in-Kotlin - 1.9.23 + 2.0.0-RC1 UTF-8 @@ -149,6 +149,13 @@ [5.10.2,) test + + org.junit.jupiter + junit-jupiter-engine + [5.10.2,) + test + + org.junit.platform junit-platform-launcher diff --git a/pom.xml b/pom.xml index c24e101c4..f20464c83 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ https://github.com/javadev/LeetCode-in-Kotlin - 1.9.23 + 2.0.0-RC1 UTF-8 @@ -143,6 +143,12 @@ [5.10.2,) test + + org.junit.jupiter + junit-jupiter-engine + [5.10.2,) + test + org.junit.platform junit-platform-launcher diff --git a/src/main/kotlin/g1301_1400/s1396_design_underground_system/UndergroundSystem.kt b/src/main/kotlin/g1301_1400/s1396_design_underground_system/UndergroundSystem.kt index 5e058ecef..9d21c15e8 100644 --- a/src/main/kotlin/g1301_1400/s1396_design_underground_system/UndergroundSystem.kt +++ b/src/main/kotlin/g1301_1400/s1396_design_underground_system/UndergroundSystem.kt @@ -2,13 +2,11 @@ package g1301_1400.s1396_design_underground_system // #Medium #String #Hash_Table #Design #2023_06_06_Time_703_ms_(99.29%)_Space_76.5_MB_(99.29%) -import java.util.LinkedList - class UndergroundSystem { private class StationAndTime(var station: String, var time: Int) private val averageTimeMap: MutableMap - private val travelerMap: MutableMap> + private val travelerMap: MutableMap> init { averageTimeMap = HashMap() @@ -16,13 +14,13 @@ class UndergroundSystem { } fun checkIn(id: Int, stationName: String, t: Int) { - travelerMap.putIfAbsent(id, LinkedList()) + travelerMap.putIfAbsent(id, ArrayList()) travelerMap[id]!!.add(StationAndTime(stationName, t)) } fun checkOut(id: Int, stationName: String, t: Int) { val list = travelerMap[id]!! - val stationAndTime = list.last + val stationAndTime = list.last() val startToEndStation: String = stationAndTime.station + "->" + stationName val duration: Int = t - stationAndTime.time if (averageTimeMap.containsKey(startToEndStation)) { diff --git a/src/main/kotlin/g1401_1500/s1425_constrained_subsequence_sum/Solution.kt b/src/main/kotlin/g1401_1500/s1425_constrained_subsequence_sum/Solution.kt index ba0ff4796..03166663b 100644 --- a/src/main/kotlin/g1401_1500/s1425_constrained_subsequence_sum/Solution.kt +++ b/src/main/kotlin/g1401_1500/s1425_constrained_subsequence_sum/Solution.kt @@ -3,23 +3,21 @@ package g1401_1500.s1425_constrained_subsequence_sum // #Hard #Array #Dynamic_Programming #Heap_Priority_Queue #Sliding_Window #Queue #Monotonic_Queue // #2023_06_07_Time_649_ms_(33.33%)_Space_51.4_MB_(100.00%) -import java.util.LinkedList - class Solution { fun constrainedSubsetSum(nums: IntArray, k: Int): Int { val n = nums.size var res = Int.MIN_VALUE - val mono = LinkedList() + val mono = ArrayList() for (i in 0 until n) { var take = nums[i] - while (mono.isNotEmpty() && i - mono.first[0] > k) { + while (mono.isNotEmpty() && i - mono.first()[0] > k) { mono.removeFirst() } if (mono.isNotEmpty()) { - val mx = Math.max(0, mono.first[1]) + val mx = Math.max(0, mono.first()[1]) take += mx } - while (mono.isNotEmpty() && take > mono.last[1]) { + while (mono.isNotEmpty() && take > mono.last()[1]) { mono.removeLast() } mono.add(intArrayOf(i, take))