Sobes.tech
Junior — Senior

Counting precious stones among the available stones

livecode

Task condition

Given two strings: jewels — a set of characters, each representing a type of gemstone, and stones — a string where each character represents a stone you have. You need to count how many characters from stones are present in jewels. The comparison is case-sensitive, meaning 'a' and 'A' are considered different types.

Example 1: Input: jewels = "aA", stones = "aAAbbbb" Output: 3

Example 2: Input: jewels = "z", stones = "ZZ" Output: 0