jewels_and_stones

  • 2022-12-14
  • 浏览 (462)

jewels_and_stones.go 源码

package leetcode

// 宝石与石头
func numJewelsInStones(J string, S string) int {
	m := make(map[rune]bool)
	for _, v := range J {
		m[v] = true
	}

	res := 0
	for _, v := range S {
		if m[v] {
			res++
		}
	}
	return res
}

你可能感兴趣的文章

array_intersection

array_intersection_ii

find_all_anagrams

0  赞