Code Lab

Modo entrevista. Temporizador de 4 min, sin pistas y sin autocompletado

Jewels and stones

FácilMap 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.

Ejemplos

countJewels('aA', 'aAAbbbb')

Devuelve 3

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

Devuelve 0

`Z` and `z` are different kinds.

Fuente

Cargando el editor…
  1. EntradacountJewels('aA', 'aAAbbbb')
    Esperado3
  2. EntradacountJewels('z', 'ZZ')
    Esperado0
  3. EntradacountJewels('ab', 'abba')
    Esperado4

Las pruebas ocultas se ejecutan al enviar