Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public int twoCitySchedCost(int[][] costs) {
- int minCost = 0;
- int[] refund = new int[costs.length];
- for (int i = 0; i < costs.length; i++) {
- minCost += costs[i][0];
- refund[i] = costs[i][0] - costs[i][1];
- }
- Arrays.sort(refund);
- int len = refund.length;
- int cnt = 0;
- while (cnt < len / 2) {
- minCost = minCost - refund[len - cnt - 1];
- cnt++;
- }
- return minCost;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement