Given an unsorted array of ex-file sizes [40,10,20,30,100,60] and a maximum of ex-150 free disk space. Adjust in all files, what will be the maximum size that you can integrate.

The simplest thing to do was to take the average of the maximum available size = 150/6 = 25 .. but since there are files whose size is less than 25, we must use a maximum of space, which means is not the right answer. Sort and scroll through the table, continue to subtract and calculate the following average until we see an above-average size. There will be special cases if all sizes are below average and we should simply return the average in this case.

The answer in this particular case is 30. I am not able to link it to a data structure or algorithm. I looked on Hackerrank and leetcode but I did not find anything similar.