To set user expectations during file uploads, Online Cloud Service "ABC", indicates how long a file will take to transfer with its upload time estimator.
Your goal is to implement a particular type of a upload time estimator. Suppose that several clients are uploading files to Dropbox at the same given moment. The
ith client uploads a file of sizesi megabytes. For a single file, upload speed is V megabytes per second, but if there are several files uploading at the same time then uploads occur simultaneously in parallel threads. For each thread the upload speed equals V / n, where n is the number of currently active threads.
Given each file's size and its upload start time, determine the upload end times.
Example
For
the output should be
sizes = [21, 10], uploadingStart = [100, 105] and V = 2the output should be
loadTimeEstimator(sizes, uploadingStart, V) = [116, 115].- During the first
5seconds only the first file is uploading at a speed of2 MB/sec. Thus, when the second file upload begins,10 MBsof the first file will already have been uploaded. - For the next
10seconds both files upload simultaneously with a speed of1 MB/seceach. - After this point (
15seconds since the first file started uploading) the second file is uploaded successfully, and only1 MBof the first file remains to be transferred. - It takes
0.5more seconds to finish uploading the first file. Rounding115.5up, we obtain116.
- [input] array.integer sizesArray of positive integers.
sizes[i]equals the size of theithfile in megabytes. - [input] array.integer uploadingStartArray of positive integers of the same length as
sizes.uploadingStart[i]represents the number of seconds that will pass from the current moment before uploading of theithfile starts. - [input] integer VA positive integer.
- [output] array.integerThe
ithelement of the result should be equal to the number of seconds that will pass from the current moment before uploading of theithfile finishes. If the upload takes a non-integer number of seconds, round it up.
Great Post Buddy.
ReplyDelete