A prospector keeps a short list of ore codes considered valuable, then empties a day's collection sack onto the table. Each character of the sack string names the code stamped on one sample. Count how many samples in the sack carry a code that appears on the valuable list. Matching is exact and case-sensitive, so a lowercase code and its uppercase twin are treated as different ore types.
Line 1: a string V, the valuable ore codes (each character is one code; codes may repeat in the list, but that never changes which codes count as valuable). Line 2: a string B, the collection sack, where each character is one sample's ore code.
A single integer: the number of characters in B that also occur, as an exact case-sensitive match, somewhere in V.
Example 1
Input
aA aAAbbbb
Expected
3
Explanation
The valuable list names both 'a' and 'A' as valuable codes. Scanning the sack "aAAbbbb", the characters 'a', 'A', 'A' each match a valuable code (3 matches), while the four 'b' characters do not, so the answer is 3.
Example 2
Input
z ZZ
Expected
0
Explanation
The valuable list contains only lowercase 'z'. The sack "ZZ" holds two uppercase 'Z' samples, and since matching is case-sensitive, uppercase 'Z' never matches lowercase 'z', so the answer is 0.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →