Company: Cashfree_5Dec
Difficulty: medium
Non Overlapping Intervals Three health care buildings are to be built on plots of land numbered consecutively from 1. Given n intervals represented by arrays starting and ending , determine the number of ways to select three non-overlapping intervals. Two intervals, [l1, r1] and [l2, r2], overlap if there is an integer that occurs in both. Interval sets must be distinct, i.e., at least one interval must differ for two sets to be considered different. Example Given: n = 5 starting = [1, 2, 4, 3, 7] ending = [3, 4, 6, 5, 8] This creates the following intervals: [1,3] , [2,4] , [4,6] , [3,5] , [7,8] . Only one valid selection of three non-overlapping intervals exists: [1,3] , [4,6] , and [7,8] . Note that intervals [1,3] and [3,5] overlap at point 3. The answer is 1. Function Description Complete the function getThreeNonOverlappingIntervals in the editor. It has the following parameters: Parameters: vector<int> starting : An array of integers representing the left endpoints of the i