EXPEDIA Coding Question – Solved

3 Live
Given two servers and the time taken to upgrade each server in seconds, denoted by t1 and t2 respectively, in one second, one server undergoes the upgrade process. The servers receive requests at certain time intervals and pause upgrades during those seconds. The servers receive requests at multiples of req1 and req2 respectively. Determine the minimum total time (in seconds) required to upgrade both servers. Notes: . Only one server undergoes the upgrade process at any given second. . There may be seconds during which no server is undergoing an upgrade. Example: req1 = 2 t1 = 3 req2 = 3 t2 = 1 The 1st server takes 3 seconds to upgrade, and it receives requests on seconds that are multiples of 2. Similarly, the 2nd server upgrades in 1 second and receives requests on seconds that are multiples of 3. The 1st server upgrades in the 1st, 3rd, and 5th seconds, while the 2nd server upgrades in the 2nd second. Note that none of the numbers from [1, 3, 5] is divisible by req1 = 2. Similarly, [2] is not divisible by req2 = 3. Thus, the minimum time required is 5 seconds. Function Description: Complete the function getMinUpgradationTime in the editor below. getMinUpgradationTime takes the following parameter(s): int req1: indicates that the first server receives requests at multiples of req1 int t1: the total time in seconds to upgrade the first server int req2: indicates that the second server receives requests at multiples of req2 int t2: the total time in seconds to upgrade the second server Returns: long: the minimum total time (in seconds) required to upgrade both servers Constraints: Β· 2 ≀ req1, req2 ≀ 3 * 10^4 Β· 1 ≀ t1, t2 ≀ 10^9 Sample Input: 2 1 FUNCTION req1 = 2 t1 = 1 Input Format For Custom Testing: Sample Case 0 Sample Input For Custom Testing: STDIN

Asked in: EXPEDIA

Image of the Question

Question Image Question Image Question Image

All Testcases Passed βœ”



Passcode Image

Solution


Please login to view the solution


Related Questions

| Given an n x m grid, where rows are numbered from 7 to n and columns from 1 to … |
| There are 'N' coders standing in a line, where i denotes the ith position of a … |
| A birthday party was attended by N number of kids, and each kid was given a uni… |
| Given a matrix of size m * n, where m denotes the number of rows (starting with… |
| A traveler is traveling from the city of Zeta to Omega. He starts with X amount… |
| As an operations engineer at Amazon, you are responsible for organizing the dis… |