File tree Expand file tree Collapse file tree 7 files changed +11
-18
lines changed
src/main/kotlin/g0001_0100
s0042_trapping_rain_water Expand file tree Collapse file tree 7 files changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ Include the following in your `pom.xml` for Maven:
20
20
<dependency >
21
21
<groupId >com.github.javadev</groupId >
22
22
<artifactId >leetcode-in-kotlin</artifactId >
23
- <version >1.3 </version >
23
+ <version >1.4 </version >
24
24
</dependency >
25
25
...
26
26
</dependencies >
@@ -29,7 +29,7 @@ Include the following in your `pom.xml` for Maven:
29
29
Gradle:
30
30
31
31
``` groovy
32
- implementation 'com.github.javadev:leetcode-in-kotlin:1.3 '
32
+ implementation 'com.github.javadev:leetcode-in-kotlin:1.4 '
33
33
```
34
34
35
35
#### Tips and Tricks
Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ repositories {
15
15
16
16
dependencies {
17
17
implementation(" org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10" )
18
- testImplementation(" org.junit.jupiter:junit-jupiter-api:[5.8.2 ,)" )
19
- testRuntimeOnly(" org.junit.jupiter:junit-jupiter-engine:[5.8.2 ,)" )
18
+ testImplementation(" org.junit.jupiter:junit-jupiter-api:[5.9.0 ,)" )
19
+ testRuntimeOnly(" org.junit.jupiter:junit-jupiter-engine:[5.9.0 ,)" )
20
20
testImplementation(" org.hamcrest:hamcrest-core:[2.2,)" )
21
21
}
22
22
@@ -25,7 +25,7 @@ tasks.test {
25
25
}
26
26
27
27
group = " com.github.javadev"
28
- version = " 1.3 -SNAPSHOT"
28
+ version = " 1.4 -SNAPSHOT"
29
29
description = " leetcode-in-kotlin"
30
30
java.sourceCompatibility = JavaVersion .VERSION_1_8
31
31
Original file line number Diff line number Diff line change 4
4
<groupId >com.github.javadev</groupId >
5
5
<artifactId >leetcode-in-kotlin</artifactId >
6
6
<packaging >jar</packaging >
7
- <version >1.3 </version >
7
+ <version >1.4 </version >
8
8
<name >leetcode-in-kotlin</name >
9
9
<description >Kotlin Solution for LeetCode algorithm problems, continually updating</description >
10
10
<url >https://github.com/javadev/LeetCode-in-Kotlin</url >
74
74
<dependency >
75
75
<groupId >org.junit.jupiter</groupId >
76
76
<artifactId >junit-jupiter-engine</artifactId >
77
- <version >[5.8.2 ,)</version >
77
+ <version >[5.9.0 ,)</version >
78
78
</dependency >
79
79
</dependencies >
80
80
</plugin >
146
146
<dependency >
147
147
<groupId >org.junit.jupiter</groupId >
148
148
<artifactId >junit-jupiter-api</artifactId >
149
- <version >[5.8.2 ,)</version >
149
+ <version >[5.9.0 ,)</version >
150
150
<scope >test</scope >
151
151
</dependency >
152
152
<dependency >
Original file line number Diff line number Diff line change 73
73
<dependency >
74
74
<groupId >org.junit.jupiter</groupId >
75
75
<artifactId >junit-jupiter-engine</artifactId >
76
- <version >[5.8.2 ,)</version >
76
+ <version >[5.9.0 ,)</version >
77
77
</dependency >
78
78
</dependencies >
79
79
</plugin >
140
140
<dependency >
141
141
<groupId >org.junit.jupiter</groupId >
142
142
<artifactId >junit-jupiter-api</artifactId >
143
- <version >[5.8.2 ,)</version >
143
+ <version >[5.9.0 ,)</version >
144
144
<scope >test</scope >
145
145
</dependency >
146
146
<dependency >
Original file line number Diff line number Diff line change @@ -7,22 +7,19 @@ package g0001_0100.s0039_combination_sum
7
7
class Solution {
8
8
fun combinationSum (candidates : IntArray , target : Int ): List <List <Int >> {
9
9
val result = mutableListOf<List <Int >>()
10
-
11
10
fun backtrack (start : Int , case : MutableList <Int >, sum : Int ) {
12
11
if (sum >= target) {
13
12
if (sum == target) {
14
13
result.add(case.toList())
15
14
}
16
15
return
17
16
}
18
-
19
17
for (i in start until candidates.size) {
20
18
case.add(candidates[i])
21
19
backtrack(i, case, sum + candidates[i])
22
20
case.removeAt(case.size - 1 )
23
21
}
24
22
}
25
-
26
23
backtrack(0 , mutableListOf (), 0 )
27
24
return result
28
25
}
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ class Solution {
12
12
var totalWater = 0
13
13
var leftPtr = 0
14
14
var rightPtr = size - 1
15
-
16
15
while (leftPtr < rightPtr) {
17
16
if (height[leftPtr] <= height[rightPtr]) {
18
17
if (maxLeft > height[leftPtr]) {
@@ -30,7 +29,6 @@ class Solution {
30
29
-- rightPtr
31
30
}
32
31
}
33
-
34
32
return totalWater
35
33
}
36
34
}
Original file line number Diff line number Diff line change @@ -9,15 +9,13 @@ class Solution {
9
9
var jumps = 0
10
10
var minJump = 0
11
11
var maxJump = 0
12
-
13
12
while (maxJump < nums.lastIndex) {
14
13
var nextJump = 0
15
- for (i in minJump.. maxJump) nextJump = maxOf(nextJump, i + nums[i])
14
+ for (i in minJump.. maxJump) { nextJump = maxOf(nextJump, i + nums[i]) }
16
15
minJump = maxJump + 1
17
16
maxJump = nextJump
18
17
jumps++
19
18
}
20
-
21
19
return jumps
22
20
}
23
21
}
You can’t perform that action at this time.
0 commit comments