BackeasyMath

Element Occurrence Counter Solution

Problem Statement

Given an array of integers, count the occurrences of each element and return the elements that occur more than 47 times.

Example 1
Input
[11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 19, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11, 23, 11]
Output
[]

Explanation: Both 11 and 23 occur 48 times in the array.

Example 2
Input
[7, 4, 7, 4, 7, 4, 7, 4, 7, 4, 7, 4]
Output
[]

Explanation: Neither 7 nor 4 occur more than 47 times in the array.

Constraints

  • The length of the arr will be at least 1 and no more than 1000.
  • Each element arr[i] will be an integer in the range [1, 1000].
  • There will be at least one element that occurs more than 47 times in the array.
  • There will be no more than 50 distinct elements in the array.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free