info@onlinelearningcenter.in (+91) 7 999 01 02 03 Get started with 45 Hours of Free course right now 

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

Dhrumil Shah
1 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