2185. Counting Words With a Given Prefix
🟩 Easy
Solution
My Solution
func prefixCount(words []string, pref string) int {
count := 0
for _, word := range words {
if len(word) >= len(pref) && word[:len(pref)] == pref {
count++
}
}
return count
}

Leetcode: link
Last updated
Was this helpful?