Loading content...
You are an archaeologist who has discovered a collection of ancient stones. Your research team has identified certain stone types as valuable treasures based on their unique markings. Given a string treasures that defines which character symbols represent valuable treasure stones, and a string collection representing all the stones you've collected, determine how many stones in your collection are actually valuable treasures.
Each character in treasures represents a unique symbol for a treasure type. Each character in collection represents one stone you have discovered. Your task is to count how many stones from your collection match any of the treasure symbols.
Important: The treasure identification is case-sensitive, meaning an uppercase letter (e.g., 'A') represents a completely different treasure type than its lowercase counterpart (e.g., 'a').
treasures = "aA"
collection = "aAAbbbb"3The treasures are 'a' and 'A'. In the collection "aAAbbbb", we have one 'a' and two 'A's (positions 0, 1, and 2), so 3 stones are treasures. The remaining 'b' stones are not treasures.
treasures = "z"
collection = "ZZ"0The only treasure type is lowercase 'z'. However, the collection contains only uppercase 'Z' stones. Since identification is case-sensitive, 'Z' is not the same as 'z', so zero stones are treasures.
treasures = "abc"
collection = "aabbcc"6The treasures are 'a', 'b', and 'c'. The collection contains two of each: "aabbcc". Since every stone matches one of the treasure types, all 6 stones are treasures.
Constraints