Round desk: Proof strip
Stuck or curious how this works? Visualize Stack Operations ↗
Inputs
readings is a list of integers (numbers with no decimal part). It may be empty, and numbers may repeat unless task 1 says otherwise.
Your tasks
- Create a list
finishTimes. Each number inreadingsis the work time needed by a job. All jobs are ready at time 0, in input order. The worker gives the first job up toktime units. If it still needs work, put it at the back of the line. Then serve the next job. Record when each job finishes, measured from time 0. Record these finish times in original job order. A job needing 0 time finishes at time 0 and uses no worker time. - Complete
roundDeskProofStripso it returnsfinishTimes. Return it, do not print it.
Example
If readings is [1, 7, 3, 4, 3] and k is 3, then finishTimes is [1, 18, 7, 17, 13] and roundDeskProofStrip returns [1, 18, 7, 17, 13].
Rules
- If
finishTimesis empty, return []. k(a whole number from 1 to 8) is the most time units a job gets in one turn.
Test data
TEST DATA 1: readings is [8, 4, 0, 3, 4] and k is 7.
TEST DATA 2: readings is [4, 4, 8, 4] and k is 7.
Examples
Input: readings = [8,4,0,3,4] k = 7 Output: [19,11,0,14,18]
finishTimes is [19, 11, 0, 14, 18]. roundDeskProofStrip returns that whole list, so return [19, 11, 0, 14, 18].
Input: readings = [4,4,8,4] k = 7 Output: [4,8,20,19]
finishTimes is [4, 8, 20, 19]. roundDeskProofStrip returns that whole list, so return [4, 8, 20, 19].
Input: readings = [] k = 6 Output: []
finishTimes is []. roundDeskProofStrip returns that whole list, so return [].
Input limits
- 0 <= input size <= 64.
- k is a whole number from 1 to 8. Answers fit in a signed 32-bit integer: -2,147,483,648 through 2,147,483,647.
- Input numbers are whole numbers from 0 through 20.
Efficiency goal
Big-O describes how the work or memory needed grows as the input gets larger.
Efficiency goal: time O(n + total/k); extra memory, including the helper list, O(n). n is the input length; total is all job work time added together. These labels describe how work and memory grow with the input.
Practice focus
Build finishTimes first, then return exactly what the tasks ask for. Follow the order, keep repeated values when the rule says so, and check the empty case.