Close
Topic list
Treasure and Jewels
EASY
30 mins
Strings
Topics (Covered in this problem)
Problem solved
Skill meter
Strings
-
-
Other topics
Problem solved
Skill meter
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Treasure and Jewels

Contributed by
Ambuj verma
Easy
0/40
Avg time to solve 30 mins
Success Rate 70 %
Share

## Problem Statement

#### Note: ‘JEWELS’ consist of distinct characters and ‘A’ and ‘a’ are treated as two different stone types.

##### For Example
``````If ‘STONES’ is “abAAc” and JEWELS is “Acd”.The number of jewels Ninja have is 3.
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````2
5 3
abAAc
Acd
4 2
acbd
Aa
``````
##### Sample Output 1:
``````3
1
``````
##### Explanation of sample input 1:
``````For the first test case,

Ninja has 3 jewels, one ‘c’ and two ‘A’.Hence, the answer is 3.

For the second test case:

Ninja has only 1 jewel, one ‘a’.Hence, the answer is 1.
``````
##### Sample Input 2:
``````2
3 1
aaa
b
4 2
abcd
Bb
``````
##### Sample Output 2:
``````0
1
``````
Auto
Console