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:
2020 <dependency >
2121 <groupId >com.github.javadev</groupId >
2222 <artifactId >leetcode-in-kotlin</artifactId >
23- <version >1.3 </version >
23+ <version >1.4 </version >
2424 </dependency >
2525 ...
2626</dependencies >
@@ -29,7 +29,7 @@ Include the following in your `pom.xml` for Maven:
2929Gradle:
3030
3131``` groovy
32- implementation 'com.github.javadev:leetcode-in-kotlin:1.3 '
32+ implementation 'com.github.javadev:leetcode-in-kotlin:1.4 '
3333```
3434
3535#### Tips and Tricks
Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ repositories {
1515
1616dependencies {
1717 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 ,)" )
2020 testImplementation(" org.hamcrest:hamcrest-core:[2.2,)" )
2121}
2222
@@ -25,7 +25,7 @@ tasks.test {
2525}
2626
2727group = " com.github.javadev"
28- version = " 1.3 -SNAPSHOT"
28+ version = " 1.4 -SNAPSHOT"
2929description = " leetcode-in-kotlin"
3030java.sourceCompatibility = JavaVersion .VERSION_1_8
3131
Original file line number Diff line number Diff line change 44 <groupId >com.github.javadev</groupId >
55 <artifactId >leetcode-in-kotlin</artifactId >
66 <packaging >jar</packaging >
7- <version >1.3 </version >
7+ <version >1.4 </version >
88 <name >leetcode-in-kotlin</name >
99 <description >Kotlin Solution for LeetCode algorithm problems, continually updating</description >
1010 <url >https://github.com/javadev/LeetCode-in-Kotlin</url >
7474 <dependency >
7575 <groupId >org.junit.jupiter</groupId >
7676 <artifactId >junit-jupiter-engine</artifactId >
77- <version >[5.8.2 ,)</version >
77+ <version >[5.9.0 ,)</version >
7878 </dependency >
7979 </dependencies >
8080 </plugin >
146146 <dependency >
147147 <groupId >org.junit.jupiter</groupId >
148148 <artifactId >junit-jupiter-api</artifactId >
149- <version >[5.8.2 ,)</version >
149+ <version >[5.9.0 ,)</version >
150150 <scope >test</scope >
151151 </dependency >
152152 <dependency >
Original file line number Diff line number Diff line change 7373 <dependency >
7474 <groupId >org.junit.jupiter</groupId >
7575 <artifactId >junit-jupiter-engine</artifactId >
76- <version >[5.8.2 ,)</version >
76+ <version >[5.9.0 ,)</version >
7777 </dependency >
7878 </dependencies >
7979 </plugin >
140140 <dependency >
141141 <groupId >org.junit.jupiter</groupId >
142142 <artifactId >junit-jupiter-api</artifactId >
143- <version >[5.8.2 ,)</version >
143+ <version >[5.9.0 ,)</version >
144144 <scope >test</scope >
145145 </dependency >
146146 <dependency >
Original file line number Diff line number Diff line change @@ -7,22 +7,19 @@ package g0001_0100.s0039_combination_sum
77class Solution {
88 fun combinationSum (candidates : IntArray , target : Int ): List <List <Int >> {
99 val result = mutableListOf<List <Int >>()
10-
1110 fun backtrack (start : Int , case : MutableList <Int >, sum : Int ) {
1211 if (sum >= target) {
1312 if (sum == target) {
1413 result.add(case.toList())
1514 }
1615 return
1716 }
18-
1917 for (i in start until candidates.size) {
2018 case.add(candidates[i])
2119 backtrack(i, case, sum + candidates[i])
2220 case.removeAt(case.size - 1 )
2321 }
2422 }
25-
2623 backtrack(0 , mutableListOf (), 0 )
2724 return result
2825 }
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ class Solution {
1212 var totalWater = 0
1313 var leftPtr = 0
1414 var rightPtr = size - 1
15-
1615 while (leftPtr < rightPtr) {
1716 if (height[leftPtr] <= height[rightPtr]) {
1817 if (maxLeft > height[leftPtr]) {
@@ -30,7 +29,6 @@ class Solution {
3029 -- rightPtr
3130 }
3231 }
33-
3432 return totalWater
3533 }
3634}
Original file line number Diff line number Diff line change @@ -9,15 +9,13 @@ class Solution {
99 var jumps = 0
1010 var minJump = 0
1111 var maxJump = 0
12-
1312 while (maxJump < nums.lastIndex) {
1413 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]) }
1615 minJump = maxJump + 1
1716 maxJump = nextJump
1817 jumps++
1918 }
20-
2119 return jumps
2220 }
2321}
You can’t perform that action at this time.
0 commit comments