-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem.txt
44 lines (28 loc) · 1.22 KB
/
problem.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Challenge: Hackerrank "Gemstones"
There is a collection of rocks where each rock has various minerals embeded in it. Each type of mineral is designated by a lowercase letter in the range ascii[a-z].
There may be multiple occurrences of a mineral in a rock. A mineral is called a gemstone if it occurs at least once in each of the rocks in the collection.
Given a list of minerals embedded in each of the rocks, display the number of types of gemstones in the collection.
Example
arr=['abcdde', 'baccd', 'eeabg'];
The minerals b and c appear in each rock, so there are gemstones.
Function Description
Complete the gemstones function :
gemstones has the following parameter(s)--> string arr[n]: an array of strings
Returns
int: the number of gemstones found.
Input Format
The first line consists of an integer , the size of .
Each of the next n lines contains a string arr[i] where each letter represents an occurence of a mineral in the current rock.
Constraints
1 <= n <= 100
1 <= arr[i] <= 100
Each composition arr[i] consists of only lower-case Latin letters ('a'-'z').
Sample Input
STDIN Function
----- --------
3 arr[] size n = 3
abcdde arr = ['abcdde', 'baccd', 'eeabg']
baccd
eeabg
Sample Output
2