admin@onlinelearningcenter.in (+91) 7 999 01 02 03

Given an array of size n and a number k, find all elements that appear more than n/k times

Dhrumil Shah
2 Posts
class Cpp
Examples:

Input:
arr = [3, 1, 2, 2, 1, 2, 3, 3]
k = 4

Output:
[2, 3]


Note that size of array is 8 (or n = 8), so we need to find all elements that appear more than 2 (for exa:- 8/4) times. There are two elements that appear more than two times, 2 and 3. 
Python
Published By : Dhrumil Shah
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Comments

Jquery Comments Plugin