50. Count Occurrences
Foundation1000 ms256 MBSolved by 0%
You are given an array of n integers and then a value k on its own line.
Print how many times k appears in the array.
Constraints - `1 ≤ n ≤ 100000` - `-1000000 ≤ a[i], k ≤ 1000000`
Input
The first line contains an integer n.
The second line contains n space-separated integers.
The third line contains an integer k.
Output
Print one integer, how many times k appears.
Input6
1 2 2 3 2 4
2
Output3
Notehas the value appearing three times
Input4
1 2 3 4
9
Output0
Notedoes not contain the value at all
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.