All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g2001_2100.s2027_minimum_moves_to_convert_string.Solution.kt Maven / Gradle / Ivy

There is a newer version: 1.32
Show newest version
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