Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 5 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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,)")
Expand All @@ -33,7 +33,9 @@ java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
}
}

publishing {
Expand Down
9 changes: 8 additions & 1 deletion pom-central.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<url>https://github.com/javadev/LeetCode-in-Kotlin</url>
</scm>
<properties>
<kotlin.version>1.9.23</kotlin.version>
<kotlin.version>2.0.0-RC1</kotlin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<ciManagement>
Expand Down Expand Up @@ -149,6 +149,13 @@
<version>[5.10.2,)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>[5.10.2,)</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<url>https://github.com/javadev/LeetCode-in-Kotlin</url>
</scm>
<properties>
<kotlin.version>1.9.23</kotlin.version>
<kotlin.version>2.0.0-RC1</kotlin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<ciManagement>
Expand Down Expand Up @@ -143,6 +143,12 @@
<version>[5.10.2,)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>[5.10.2,)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@ 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<String, DoubleArray>
private val travelerMap: MutableMap<Int, LinkedList<StationAndTime>>
private val travelerMap: MutableMap<Int, ArrayList<StationAndTime>>

init {
averageTimeMap = HashMap()
travelerMap = HashMap()
}

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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IntArray>()
val mono = ArrayList<IntArray>()
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))
Expand Down