![JAR search and dependency download from the Maven repository](/logo.png)
g2001_2100.s2027_minimum_moves_to_convert_string.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 g2001_2100.s2027_minimum_moves_to_convert_string
// #Easy #String #Greedy #2023_06_23_Time_142_ms_(100.00%)_Space_34.1_MB_(100.00%)
class Solution {
fun minimumMoves(s: String): Int {
var r = 0
var i = 0
val sArray = s.toCharArray()
while (i < sArray.size) {
if (sArray[i] == 'X') {
r++
i += 2
}
i++
}
return r
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy