Code Lab

Modo entrevista. Cronômetro de 4 min, sem dicas e sem autocompletar

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.

Exemplos

countJewels('aA', 'aAAbbbb')

Retorna 3

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

Retorna 0

`Z` and `z` are different kinds.

Fonte

Carregando o editor...
  1. EntradacountJewels('aA', 'aAAbbbb')
    Esperado3
  2. EntradacountJewels('z', 'ZZ')
    Esperado0
  3. EntradacountJewels('ab', 'abba')
    Esperado4

Os testes ocultos rodam no envio