Count Days Without Meetings

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.
I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.
You are given a positive integer days representing the total number of days an employee is available for work (starting from day 1). You are also given a 2D array meetings of size n where, meetings[i] = [start_i, end_i] represents the starting and ending days of meeting i (inclusive).
Return the count of days when the employee is available for work but no meetings are scheduled.
Note: The meetings may overlap.
LeetCode Problem - 3169
class Solution {
public int countDays(int days, int[][] meetings) {
// Sort the meetings array based on the start time of each meeting
Arrays.sort(meetings, Comparator.comparingInt(a -> a[0]));
// Initialize the start to one day before the first meeting's start time
// and end to the end time of the first meeting
int start = meetings[0][0] - 1, end = meetings[0][1];
// Iterate through the sorted meetings starting from the second meeting
for (int i = 1; i < meetings.length; i++) {
// If there is a gap between the end of the current meeting and the start of the next meeting,
// add the number of days in the gap to the start
if (end < meetings[i][0]) start += meetings[i][0] - end - 1;
// Update the end to be the maximum of the current end and the end of the current meeting
end = Math.max(end, meetings[i][1]);
}
// Calculate the number of days between the total days and the end time of the last meeting
// and add this to the start to get the total count of days
return start + days - end;
}
}




