I've a List<Long> (A) indicating the free sizes available for different partitions.
Users come to ask with a List<Long> ( B) indicating the file sizes they want to store.
Now if any Long (from B) can fit into any free size in A, we want to re-use the partition, otherwise create new partition for them.
How can I know if any of the Long value from B have value less than any of the Long in A.
If I use iterative approach to scan through A and find out if any of B will fit, it will cause O(n^2) runtime, but can we do better ?
Any Data structure exists for this kind of problem ?