Check if All the Integers in a Range Are Covered

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 2D integer array ranges and two integers left and right. Each ranges[i] = [start<sub>i</sub>, end<sub>i</sub>] represents an inclusive interval between start<sub>i</sub> and end<sub>i</sub>.
Return true if each integer in the inclusive range [left, right] is covered by at least one interval in ranges. Return false otherwise.
An integer x is covered by an interval ranges[i] = [start<sub>i</sub>, end<sub>i</sub>] if start<sub>i</sub> <= x <= end<sub>i</sub>.
LeetCode Problem - 1893
class Solution {
// Method to check if all numbers in the range [left, right] are covered by any of the subranges in 'ranges'
public boolean isCovered(int[][] ranges, int left, int right) {
// Set to store all numbers that are covered by the given ranges
Set<Integer> coveredNumbers = new HashSet<>();
// Iterate over each range in 'ranges'
for (int[] range : ranges) {
// For each range, add all numbers from the start to the end of the range to the set
for (int i = range[0]; i <= range[1]; i++) {
coveredNumbers.add(i); // Add the current number to the set
}
}
// Check if all numbers in the range [left, right] are in the set of covered numbers
for (int i = left; i <= right; i++) {
// If any number in the range [left, right] is not in the set, return false
if (!coveredNumbers.contains(i)) {
return false;
}
}
// If all numbers in the range [left, right] are covered, return true
return true;
}
}




