Minimum Server Upgradation Time
Problem statement
There are two servers needing $t1$ and $t2$ seconds of upgrade work respectively. In each real second, only one server may undergo one second of its upgrade. The servers receive requests at fixed intervals and pause upgrades during those seconds: server 1 cannot be upgraded on seconds that are multiples of $req1$, and server 2 cannot be upgraded on seconds that are multiples of $req2$. There may be seconds during which no server is upgraded. Determine the minimum total elapsed time (in seconds) required to fully upgrade both servers.
Implement:
def getMinUpgradationTime(req1, req2, t1, t2): # returns int: the minimum total elapsed seconds to upgrade both servers
Constraints: $2 \le req1, req2 \le 3 \times 10^4$; $1 \le t1, t2 \le 10^4$.
Example: $req1 = 2$, $t1 = 3$, $req2 = 3$, $t2 = 1$. Server 1 needs 3 seconds and is blocked on multiples of 2; server 2 needs 1 second and is blocked on multiples of 3. Server 1 can upgrade in seconds 1, 3, and 5, while server 2 upgrades in second 2. None of $\{1, 3, 5\}$ is divisible by $req1 = 2$, and $\{2\}$ is not divisible by $req2 = 3$. The minimum time required is 5 seconds.
Show hint
Instead of deciding who works in each second, can you test whether a given total time is enough?
Relevant roles: ML Engineer, MLOps Engineer, Forward Deployed Engineer and AI Engineer.