Question: write C++ program 2 Cover intervals You are given a sorted unique integer array A. An interval [a, b] is the set of all integers

write C++ program

2 Cover intervals You are given a sorted unique integer array A. An interval [a, b] is the set of all integers from a to b (inclusive). You are to write a function called ECSmallestCoverIntervals that returns the smallest number of intervals of A that cover all the numbers in the array exactly. That is, each element of A is covered by exactly one of the intervals, and there is no integer x such that x is in one of the intervals but not in A. For example, suppose A = [0, 1, 2, 4, 5, 7], then the function returns 3: there are three cover intervals: [0, 2], [4, 5], [7, 7]. As another example, for B = [0, 2, 3, 4, 6, 8, 9], the function returns 4.

starter code

// Given a sorted list, find the smallest number of covering intervals // For example, if A={1,2,3,5,6,9}, there are three covering intervals [1,3], [5,6] and [9]

int ECSmallestCoverIntervals(const int arrInts[], int szArr) { // arrInts: sorted array of integers; szArr: number of integers in the array // Your code here

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!