From 6c2c7f3c80bb431692821cf4e3fd7da46d74657b Mon Sep 17 00:00:00 2001 From: Priyanka T Date: Thu, 4 Jun 2020 20:45:40 +0530 Subject: [PATCH] Create TwoCityScheduling.cpp --- Week 1/TwoCityScheduling.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Week 1/TwoCityScheduling.cpp diff --git a/Week 1/TwoCityScheduling.cpp b/Week 1/TwoCityScheduling.cpp new file mode 100644 index 0000000..08bdf2f --- /dev/null +++ b/Week 1/TwoCityScheduling.cpp @@ -0,0 +1,29 @@ +/* +There are 2N people a company is planning to interview. The cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th person to city B is costs[i][1]. +Return the minimum cost to fly every person to a city such that exactly N people arrive in each city. + +Example 1: +Input: [[10,20],[30,200],[400,50],[30,20]] +Output: 110 +Explanation: +The first person goes to city A for a cost of 10. +The second person goes to city A for a cost of 30. +The third person goes to city B for a cost of 50. +The fourth person goes to city B for a cost of 20. +The total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interviewing in each city. +*/ +class Solution { +public: + int twoCitySchedCost(vector>& costs) { + int mincost=0; + for(int i=0;i refund; + for(int i=0;i