Jewels and Stones
You're given stringsJ
representing the types of stones that are jewels, andS
representing the stones you have. Each character inS
is a type of stone you have. You want to know how many of the stones you have are also jewels.
The letters inJ
are guaranteed distinct, and all characters inJ
andS
are letters. Letters are case sensitive, so"a"
is considered a different type of stone from"A"
.
Example 1:
Example 2:
Note:
S
andJ
will consist of letters and have length at most 50.The characters in
J
are distinct.
Here is a solution.
Last updated