Ctrl K

Counting the Precious Finds

Easy
A prospector has washed a pan of gravel. Each find is written as a letter in the string finds; the letter names the kind of stone. The string precious lists the valuable kinds, each exactly once. Return how many finds are of a precious kind. Case matters: a and A are different kinds.
Example 1
precious="gR", finds="rgGRgx" → 3

The precious kinds are g and R. The finds hold two g and one R; r and G are different kinds. That makes 3.

Example 2
precious="q", finds="QQQ" → 0

Case matters: Q is not q, so nothing found is precious.

Constraints
  • 1 ≤ len(precious) ≤ 50
  • 0 ≤ len(finds) ≤ 50
  • Both strings consist of English letters
  • All characters of precious are distinct
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasySame Letter Cipher EasySame Letters, Reshuffled EasySame When Flipped EasyShuffle Into a Palindrome Easy
loading Python…
Input
precious="gR", finds="rgGRgx"
Expected
3

Run checks the first 3 tests in your browser. Submit checks all 90 tests on the server, hidden ones included.