Leetcode Note: Go - Mimimum Moves to Convert String

Minimum Moves to Convert String - LeetCode
https://leetcode.com/problems/minimum-moves-to-convert-string/

  • Go 言語で取り組んだメモ

回答

Golang solution with explanation and images - Minimum Moves to Convert String - LeetCode
https://leetcode.com/problems/minimum-moves-to-convert-string/solutions/1502120/golang-solution-with-explanation-and-images/

func minimumMoves(s string) int {
    res := 0
    
    for i := 0; i < len(s); i++ {
        if s[i] == 'X' {
            i += 2
            res++
        }
    }
    
    return res
}