samedi 4 septembre 2021

Find the minimum time

The problem statement is ->

We want to scan N documents using two scanners. If S1 and S2 are the time taken by the scanner 1 and scanner 2 to scan a single document, find the minimum time required to scan all the N documents.

Example:-

S1 = 2, S2 = 4, N = 2

Output: 4

Explanation: Here we have two possibilities. Either scan both documents in scanner 1 or scan one document in each scanner. In both the cases time required is 4.

I came up with a solution where we find all the combinations and insert them into the set. The minimum value will be the first element in the set.

The problem is the solution will have time complexity of O(n), but the accepted time complexity is O(logn).

I am thinking on the lines of binary search but can't come up with a solution.

What should be the approach?

Aucun commentaire:

Enregistrer un commentaire