Majority Element General
easy
1. Given an array of size 'N' and an element K. 2. Task is to find all elements that appears more than N/K times in array. 3. Return these elements in an ArrayList in sorted order.
Constraints
1 <= N <= 10^4 1 <= a[i] <= 10^6 1 <= k <= N
Format
Input
N = 8 arr[] = [3, 1, 2, 2, 1, 2, 3, 3] k = 4 Note : Input is managed for you.
Output
[2, 3] Note : Output is managed for you.
Example
Sample Input
8
3 1 2 2 1 2 3 3
4
Sample Output
[2, 3]