Hi everyone,
I came across the following question:
Given an array (not sorted) of size N (1 <= N <= 1000) containing values in range 1 <= arr[i] <= 1000000. We have to distribute these elements into k-buckets (1 <= k <= 20) such that
If I sort the array and start placing the elements in buckets starting from largest elements in modulo fashion, then number of elements in all the buckets are almost same. But if the array values are skewed, sum of elements in some of the buckets are very large compared to other bucket.
Instead of sorting, I thought of using min-heap but could not come up with the solution.
Any suggestions?