FastPrepTask Scheduling
Problems/Task Scheduling

Task Scheduling

Snowflake logoSnowflake● HardINTERNOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

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 nth task is expected to take time[n] units of time to complete and the cost of processing the task on the paid server is cost[n]. 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

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

Complete the function getMinCost in the editor.

The function getMinCost has the following parameter:

  • int cost[n]: the costs of scheduling the tasks on a remote server
  • int time[n]: the times taken to run the tasks on a remote server

Return:

int: the minimum cost to complete all the tasks

Possible solution hint: Need an O(n2) DP, in the form of DFS to judge one by one, which is equivalent to traversing all the cases ☕️ :)

Examples

Example 1

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

The first task must be scheduled on the paid server for a cost of 1 and it takes 3 units of time to complete. In the meantime, the other three tasks are executed on the free server for no cost as the free server takes only 1 unit to complete any task. Return the total cost, 1.

Example 2

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

The first and the second tasks can be scheduled on the paid server and in parallel. The last two can be scheduled on the free server. The total cost is 1 + 2 = 3.

Constraints

  • 1 ≤ n ≤ 105
  • 1 ≤ cost[i] ≤ 106
  • 1 ≤ time[i] ≤ 107

More Snowflake interview questions

  • Connect Four from the Last MovePHONE SCREEN · Seen Nov 2026
  • Minimum Edits to a Perfect Binary TreePHONE SCREEN · Seen Nov 2026
  • Parallel Courses IIIONSITE INTERVIEW · Seen Nov 2026
  • Safest Shortest Path Through a GridOA · Seen Nov 2026
  • Configurable Per-Client Token BucketsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Find Valid SET Card TriplesOA · PHONE SCREEN · Seen Nov 2026
  • LFU CacheOA · ONSITE INTERVIEW · Seen Nov 2026
  • Minimum Index Distance Between Person and CakeOA · PHONE SCREEN · Seen Nov 2026
  • Minimum N-ary Tree Depth DeletionsOA · PHONE SCREEN · Seen Nov 2026
  • Sum of Binary Tree Boundary NodesOA · PHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Minimum Cost Path with TeleportationsAmazon · OA
  • Minimum Satellite Data Transfer IterationsHSBC · OAHSBC interview questions
  • Minimum Cost to Select People for Skill QuotasVisa · OAVisa interview questions
  • Maximize Wall HitsOpenAI · OAOpenAI interview questions
  • The Best Subsequence || Find the minimum of special value of a subsequenceGE Vernova · OA
  • Find Niceness 🌺Goldman Sachs · OAGoldman Sachs interview questions
  • Longest Increasing Path in a MatrixNutanix · OANutanix interview questions
  • Alternating Jumps to the Last IndexExpedia · OAExpedia interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Minimum Edit-Distance String for Each QueryTarget · OA

Snowflake interview experiences

  • Snowflake AI Coding Interview, Experienced Hires: 3 Experiences
All Snowflake interview questionsSee Snowflake hiring insights
Saved
class Solution {
    public int snowflakegetMinCost(int[] cost, int[] time) {
      //write your code here


    }

}
Checking account…