(Easy) Two City Scheduling LeetCode
class Solution { public int twoCitySchedCost(int[][] costs) { if(costs[0].length ==0||costs.length==0) return 0; int [] arr = new int[costs.length]; int sum = 0; for(int i = 0; i< costs.length; i++){ arr[i] = costs[i][0]-costs[i][1]; sum = sum + costs[i][1]; } Arrays.sort(arr); for(int j = 0; j< costs.length/2; j++){ sum = sum +arr[j]; } return sum; } }