deno.land / x / masx200_leetcode_test@10.6.5 / counting-words-with-a-given-prefix / index.go

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package index
import "strings"
func prefixCount(words []string, pref string) int { return ReduceSlice(words, func(a int, v string) int { if strings.HasPrefix(v, pref) { return a + 1 } return a }, 0)}
func ReduceSlice(s []string, c func(a int, v string) int, i int) int {
for _, v := range s { i = c(i, v) } return i}
masx200_leetcode_test

Version Info

Tagged at
a year ago