Skip to content

Commit f9587fc

Browse files
authored
Kotlin 2.0.0
1 parent fbb0a53 commit f9587fc

File tree

6 files changed

+28
-17
lines changed

6 files changed

+28
-17
lines changed

Diff for: .github/workflows/codeql.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
uses: actions/checkout@v4
5353

5454
- name: Set up JDK 17
55-
uses: actions/setup-java@v3
55+
uses: actions/setup-java@v4
5656
with:
5757
distribution: 'temurin'
5858
java-version: '17'

Diff for: build.gradle.kts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
kotlin("jvm") version "1.9.23"
2+
kotlin("jvm") version "2.0.0-RC1"
33
jacoco
44
id("org.sonarqube") version "5.0.0.4638"
55
id("com.diffplug.spotless") version "6.12.0"
@@ -14,7 +14,7 @@ repositories {
1414
}
1515

1616
dependencies {
17-
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.23")
17+
implementation("org.jetbrains.kotlin:kotlin-stdlib:2.0.0-RC1")
1818
testImplementation("org.junit.jupiter:junit-jupiter:[5.10.2,)")
1919
testImplementation("org.hamcrest:hamcrest-core:[2.2,)")
2020
testImplementation("org.zapodot:embedded-db-junit-jupiter:[2.1.1,)")
@@ -33,7 +33,9 @@ java.sourceCompatibility = JavaVersion.VERSION_11
3333
java.targetCompatibility = JavaVersion.VERSION_11
3434

3535
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
36-
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
36+
compilerOptions {
37+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
38+
}
3739
}
3840

3941
publishing {

Diff for: pom-central.xml

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<url>https://github.com/javadev/LeetCode-in-Kotlin</url>
2828
</scm>
2929
<properties>
30-
<kotlin.version>1.9.23</kotlin.version>
30+
<kotlin.version>2.0.0-RC1</kotlin.version>
3131
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3232
</properties>
3333
<ciManagement>
@@ -149,6 +149,13 @@
149149
<version>[5.10.2,)</version>
150150
<scope>test</scope>
151151
</dependency>
152+
<dependency>
153+
<groupId>org.junit.jupiter</groupId>
154+
<artifactId>junit-jupiter-engine</artifactId>
155+
<version>[5.10.2,)</version>
156+
<scope>test</scope>
157+
</dependency>
158+
152159
<dependency>
153160
<groupId>org.junit.platform</groupId>
154161
<artifactId>junit-platform-launcher</artifactId>

Diff for: pom.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<url>https://github.com/javadev/LeetCode-in-Kotlin</url>
2727
</scm>
2828
<properties>
29-
<kotlin.version>1.9.23</kotlin.version>
29+
<kotlin.version>2.0.0-RC1</kotlin.version>
3030
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3131
</properties>
3232
<ciManagement>
@@ -143,6 +143,12 @@
143143
<version>[5.10.2,)</version>
144144
<scope>test</scope>
145145
</dependency>
146+
<dependency>
147+
<groupId>org.junit.jupiter</groupId>
148+
<artifactId>junit-jupiter-engine</artifactId>
149+
<version>[5.10.2,)</version>
150+
<scope>test</scope>
151+
</dependency>
146152
<dependency>
147153
<groupId>org.junit.platform</groupId>
148154
<artifactId>junit-platform-launcher</artifactId>

Diff for: src/main/kotlin/g1301_1400/s1396_design_underground_system/UndergroundSystem.kt

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,25 @@ package g1301_1400.s1396_design_underground_system
22

33
// #Medium #String #Hash_Table #Design #2023_06_06_Time_703_ms_(99.29%)_Space_76.5_MB_(99.29%)
44

5-
import java.util.LinkedList
6-
75
class UndergroundSystem {
86
private class StationAndTime(var station: String, var time: Int)
97

108
private val averageTimeMap: MutableMap<String, DoubleArray>
11-
private val travelerMap: MutableMap<Int, LinkedList<StationAndTime>>
9+
private val travelerMap: MutableMap<Int, ArrayList<StationAndTime>>
1210

1311
init {
1412
averageTimeMap = HashMap()
1513
travelerMap = HashMap()
1614
}
1715

1816
fun checkIn(id: Int, stationName: String, t: Int) {
19-
travelerMap.putIfAbsent(id, LinkedList())
17+
travelerMap.putIfAbsent(id, ArrayList())
2018
travelerMap[id]!!.add(StationAndTime(stationName, t))
2119
}
2220

2321
fun checkOut(id: Int, stationName: String, t: Int) {
2422
val list = travelerMap[id]!!
25-
val stationAndTime = list.last
23+
val stationAndTime = list.last()
2624
val startToEndStation: String = stationAndTime.station + "->" + stationName
2725
val duration: Int = t - stationAndTime.time
2826
if (averageTimeMap.containsKey(startToEndStation)) {

Diff for: src/main/kotlin/g1401_1500/s1425_constrained_subsequence_sum/Solution.kt

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@ package g1401_1500.s1425_constrained_subsequence_sum
33
// #Hard #Array #Dynamic_Programming #Heap_Priority_Queue #Sliding_Window #Queue #Monotonic_Queue
44
// #2023_06_07_Time_649_ms_(33.33%)_Space_51.4_MB_(100.00%)
55

6-
import java.util.LinkedList
7-
86
class Solution {
97
fun constrainedSubsetSum(nums: IntArray, k: Int): Int {
108
val n = nums.size
119
var res = Int.MIN_VALUE
12-
val mono = LinkedList<IntArray>()
10+
val mono = ArrayList<IntArray>()
1311
for (i in 0 until n) {
1412
var take = nums[i]
15-
while (mono.isNotEmpty() && i - mono.first[0] > k) {
13+
while (mono.isNotEmpty() && i - mono.first()[0] > k) {
1614
mono.removeFirst()
1715
}
1816
if (mono.isNotEmpty()) {
19-
val mx = Math.max(0, mono.first[1])
17+
val mx = Math.max(0, mono.first()[1])
2018
take += mx
2119
}
22-
while (mono.isNotEmpty() && take > mono.last[1]) {
20+
while (mono.isNotEmpty() && take > mono.last()[1]) {
2321
mono.removeLast()
2422
}
2523
mono.add(intArrayOf(i, take))

0 commit comments

Comments
 (0)