![JAR search and dependency download from the Maven repository](/logo.png)
g2701_2800.s2739_total_distance_traveled.Solution.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-kotlin Show documentation
Show all versions of leetcode-in-kotlin Show documentation
Kotlin-based LeetCode algorithm problem solutions, regularly updated
package g2701_2800.s2739_total_distance_traveled
// #Easy #Math #Simulation #2023_08_05_Time_177_ms_(100.00%)_Space_35.9_MB_(92.11%)
import kotlin.math.min
class Solution {
fun distanceTraveled(mainTank: Int, additionalTank: Int): Int {
val transferableTimes = (mainTank - 1) / 4
val transferredLiters = min(transferableTimes, additionalTank)
return (mainTank + transferredLiters) * 10
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy