Recently encountered this question in a placement test.

I am given an array of numbers, not necessarily unique, and the size of a group. Let the array be denoted by 𝐵 and the size of the group be 𝐴.

I need to find the maximum number of groups with the exact same contents and of size 𝐴 that can be made from the elements of 𝐵. Once an element is used in a group it is exhausted. A group can have more than one element with the same value as long as the element is still available in 𝐵.

Example:

- If the input array is {1,2,3,1,2,3,4}, and the group size is 3 the maximum number of groups that can be made is 2, which are {1,2,3} and {1,2,3}.
- If the input array is {1,3,3,3,6,3,10}, and the group size is 4 the maximum number of groups that can be made is 1, which is {1,3,3,3}.

Length of 𝐵 can be as large as 10^5 and 𝐴 can also be as large as 10^5.

Please help me find a greedy or dynamic approach to the problem and how to solve it.