A hiring tool books travel for an even number of interviewers. Exactly half must fly to office A and half to office B. costs[i] is [costToA, costToB] for interviewer i.
Write cheapestSplit(costs) that returns the smallest total travel cost that sends exactly half of the interviewers to each office.
Input: costs = [[10,20],[30,200],[400,50],[30,20]] Output: 110
Send the first two to A (10 + 30) and the last two to B (50 + 20).
Input: costs = [[5,9],[7,8]] Output: 13
Sending the first to A and the second to B costs 5 + 8 = 13; the other way costs 16.
costs.length is even, 0 <= costs.length <= 2000001 <= costToA, costToB <= 1000Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #574 Split Interviewers Between Two Offices. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.