Leetcode Note: Go - Count Vowel Substrings of a String

Count Vowel Substrings of a String - LeetCode
https://leetcode.com/problems/count-vowel-substrings-of-a-string/description/

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

回答

[Go] Easy Solution - Count Vowel Substrings of a String - LeetCode
https://leetcode.com/problems/count-vowel-substrings-of-a-string/solutions/1564080/go-easy-solution/

func countVowelSubstrings(word string) int {
    ans := 0
    for i:=0; i<len(word); i++ {
        check := make(map[byte]int)
        for j:=i; j<len(word); j++ {
            if strings.Contains("aeiou", string(word[j])) {
                check[word[j]] += 1
            } else {
                break
            }
            if len(check) == 5 {
                ans += 1
            }
        }
    }
    return ans
}