Learn
Exam

Count Specific Element in Array 1

Difficulty
STARTER

Problem

Given a natural number n and an array numbers of natural number elements, write a function solution that returns the count of n in numbers.


Constraints

  • n and each element in numbers are natural numbers up to 10.
  • numbers is not empty, and its length does not exceed 100.

Test Case

Test Case Number n numbers return
1 1 [1, 2, 3, 4] 1
2 5 [5, 5, 5, 5, 5, 5, 5] 7
3 3 [4, 5, 6, 7, 8, 9] 0

Explanation for Test Case 1

  • The count of 1 in numbers is 1, so the return value is 1.

Explanation for Test Case 2

  • The count of 5 in numbers is 7, so the return value is 7.

Explanation for Test Case 3

  • Since 3 does not exist in numbers, the return value is 0.