FastPrepGet Minimum Cost
Problems/Get Minimum Cost

Get Minimum Cost

The D.E. Shaw Group logoThe D.E. Shaw Group● MediumOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

Source note: 2026-07-17 — The original screenshot is inconsistent: its table gives time=[1,2,3,2] and answer 3, while its explanation describes a different input and answer 1. This version follows the table and answer 3.

The data analysts of Hackerland want to schedule some long running tasks on remote servers optimally to minimize the cost of running them locally. The analysts have two servers, a paid one and a free one. The free server can be used only if the paid server is occupied.

The task is expected to take time units of time to complete and the cost of processing the task on the paid server is cost. The task can be run on the free server only if some task is already running on the paid server. The cost of the free server is 0 and it can process any task in 1 unit of time.

Find the minimum cost to complete all the tasks if tasks are scheduled optimally.

Function

getMinimumCost(time: int[], cost: int[]) → int

Complete the function getMinimumCost in the editor.

getMinimumCost has the following parameters:

  1. 1. int[] time: an array of integers representing the time units required for each task
  2. 2. int[] cost: an array of integers representing the cost of processing each task on the paid server

Returns int: the minimum cost to complete all tasks

Examples

Example 1

time = [1, 2, 3, 2]cost = [1, 2, 3, 2]return = 3

Schedule the third task on the paid server for a cost of 3. It occupies the paid server for 3 time units, so the other three tasks can each run for 1 time unit on the free server. The total cost is 3. A lower cost is impossible: paying only for the cost-1 task covers 2 tasks in total, while paying only for either cost-2 task covers at most 3 tasks.

More The D.E. Shaw Group interview questions

  • IPOPHONE SCREEN · Seen Nov 2026
  • Print Numbers in Turn with Three ThreadsPHONE SCREEN · Seen Nov 2026
  • Subarray Product Less Than KPHONE SCREEN · Seen Nov 2026
  • Koko Eating BananasPHONE SCREEN · Seen Nov 2026
  • Sum of Smallest Non-DivisorsPHONE SCREEN · Seen Nov 2026
  • Count Lucky TicketsOA · Seen Nov 2026
  • Count Palindrome Addition ChoicesOA · Seen Nov 2026
  • Coordinate Odd and Even Workers in OrderONSITE INTERVIEW · Seen Oct 2026
  • Minimum Taps to Water a GardenONSITE INTERVIEW · Seen Oct 2026
  • Remove the Fewest Magic BeansPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Hiking Club Fastest PaceInfosys · OAInfosys interview questions
  • Find Minimum TimeAlphaSense · OA
  • Find Minimum TimeBlackRock · OABlackRock interview questions
  • Maximum Easy Tasks After RearrangingIBM · OAIBM interview questions
  • Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
  • Minimum Cost of Every K-Capable Model SetTikTok · OATikTok interview questions
  • Maximum Distinct Values After Unit AdjustmentsBirla Pivot · OA
  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Minimum Distinct Prefix CostGoldman Sachs · OAGoldman Sachs interview questions
  • Maximize Minimum Deployment DifficultyJP Morgan Chase · OAJP Morgan Chase interview questions
All The D.E. Shaw Group interview questionsSee The D.E. Shaw Group hiring insights
Saved
class Solution {
    public int getMinimumCost(int[] time, int[] cost) {
        // write your code here
    }

}
Checking account…