Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Created January 9, 2025 07:35
Show Gist options
  • Save lbvf50mobile/be60947a386a1759d07e775469e10d35 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/be60947a386a1759d07e775469e10d35 to your computer and use it in GitHub Desktop.
Leetcode: 2185. Counting Words With a Given Prefix
// Leetcode: 2185. Counting Words With a Given Prefix
// https://leetcode.com/problems/counting-words-with-a-given-prefix/submissions/1502707677/?envType=daily-question&envId=2025-01-09
// = = = = = = = = = = = = = =
// Accepted.
// Thanks God, Jesus Christ!
// = = = = = = = = = = = = = =
// Runtime: 0 ms Beats 100.00%
// Memory: 5.45 MB Beats 42.37%
// 2025.01.09 Daily Challenge.
package main
import (
// "fmt"
"strings"
)
func prefixCount(words []string, pref string) int {
ans := 0
for _, w := range words {
if 0 == strings.Index(w, pref) {
ans += 1
}
}
return ans
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment