package weekContest.A400.A2; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * @ProjectName: LeetCode * @FileName: Solution * @Author: 杨逸 * @Data:2024/6/2 10:18 * @Description: */ public class Solution { public int countDays(int days, int[][] meetings) { Arrays.sort(meetings, (a, b) -> { if (a[0] > b[0]){ return 1; }else if (a[0] > b[0] && a[1] < b[1]){ return 1; } return a[0] - b[0]; }); int endDay = 0; int result = 0; for (int[] meeting : meetings) { if (meeting[0]<=endDay){ //连续的会议 endDay = Math.max(endDay,meeting[1]); }else { result+=meeting[0]-endDay-1; endDay = meeting[1]; } } return result+=days-endDay; } }