Code Lab

Mode entretien. Minuteur de 4 min, sans indices ni autocomplétion

Jewels and stones

FacileMap and Set4 min

Every character of the string jewels is one kind of jewel. Every character of the string stones is one stone you have.

Write a function countJewels(jewels, stones) that counts how many of your stones are jewels. Case matters, a and A are different kinds.

Exemples

countJewels('aA', 'aAAbbbb')

Renvoie 3

The jewels here are one `a` and two `A` stones.
countJewels('z', 'ZZ')

Renvoie 0

`Z` and `z` are different kinds.

Source

Chargement de l'éditeur...
  1. EntréecountJewels('aA', 'aAAbbbb')
    Attendu3
  2. EntréecountJewels('z', 'ZZ')
    Attendu0
  3. EntréecountJewels('ab', 'abba')
    Attendu4

Les tests cachés se lancent à la soumission