Problem
Ask
Submissions

Problem: Two City Scheduling

Medium
30 min
Explore how to solve the Two City Scheduling problem by applying greedy techniques. Understand how to assign candidates to two locations evenly while minimizing the total travel cost. This lesson guides you through problem assessment, constraints, and implementing a cost-effective solution.

Statement

A recruiter plans to hire n\textbf{\textit{n}} people and conducts their interviews at two different locations of the company. He evaluates the cost of inviting candidates to both these locations. The plan is to invite 50% at one location, and the rest at the other location, keeping costs to a minimum.

We are given an array, costs, where costs[i]=[aCosti,bCosti]costs[i] = [aCost_i, bCost_i], the cost of inviting the ithi^{th} person to City AA is aCostiaCost_i, and the cost of inviting the same person to City BB is bCostibCost_i.

You need to determine the minimum cost to invite all the candidates for the interview such that exactly n/2\textbf{\textit{n/2}} people are invited in each city.

Constraints:

  • 22 \leq costs.length 100\leq 100
  • costs.length is even
  • 1aCosti,bCosti10001 \leq aCost_i, bCost_i \leq 1000
Problem
Ask
Submissions

Problem: Two City Scheduling

Medium
30 min
Explore how to solve the Two City Scheduling problem by applying greedy techniques. Understand how to assign candidates to two locations evenly while minimizing the total travel cost. This lesson guides you through problem assessment, constraints, and implementing a cost-effective solution.

Statement

A recruiter plans to hire n\textbf{\textit{n}} people and conducts their interviews at two different locations of the company. He evaluates the cost of inviting candidates to both these locations. The plan is to invite 50% at one location, and the rest at the other location, keeping costs to a minimum.

We are given an array, costs, where costs[i]=[aCosti,bCosti]costs[i] = [aCost_i, bCost_i], the cost of inviting the ithi^{th} person to City AA is aCostiaCost_i, and the cost of inviting the same person to City BB is bCostibCost_i.

You need to determine the minimum cost to invite all the candidates for the interview such that exactly n/2\textbf{\textit{n/2}} people are invited in each city.

Constraints:

  • 22 \leq costs.length 100\leq 100
  • costs.length is even
  • 1aCosti,bCosti10001 \leq aCost_i, bCost_i \leq 1000