Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int minimumTotalCost(int[] departures, int[] returns, int minGap) {
- int res = Integer.MAX_VALUE;
- int minDeparture = Integer.MAX_VALUE;
- for (int R = minGap; R < departures.length; R++) {
- minDeparture = Math.min(minDeparture, departures[R - minGap]);
- res = Math.min(res, returns[R] + minDeparture);
- }
- return res == Integer.MAX_VALUE ? -1 : res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement