- Related Questions & Answers
- C++ program to find the best fit rectangle that covers a given point
- XOR of all the elements in the given range [L, R] in C++
- JavaScript array: Find all elements that appear more than n times
- Check if an array contains all elements of a given range in Python
- Find permutation of first N natural numbers that satisfies the given condition in C++
- Find the largest interval that contains exactly one of the given N integers In C++
- Count numbers in a range that are divisible by all array elements in C++
- Print all possible combinations of r elements in a given array of size n in C++
- Count all possible N digit numbers that satisfy the given condition in C++
- Find a range of composite numbers of given length in C++
- Count number of smallest elements in given range in C++
- Get the range of elements in a C# list
- Find smallest number n such that n XOR n+1 equals to given k in C++
- Count array elements that divide the sum of all other elements in C++
- Find all good indices in the given Array in Python\n

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Suppose we have a n ranges containing L and R. We have to check or find the index of 0 – based of the range which covers all the other given n – 1 ranges. If there is no such range, display -1. For example, if L = [2, 4, 3, 1], and R = [4, 6, 7, 9], then the output is 3. So it means the range at 3rd index (1 to 9) covers all the elements of other n – 1 ranges.

Since all L and R points are distinct, find the range of smallest L and largest R point, if both are the same range, then it indicates all other ranges lie within it. Otherwise it is not possible.

#include<iostream> using namespace std; int fact (int n) { if (n == 0) return 1; return n * fact(n-1); } void showRange(int n) { int a = fact(n + 2) + 2; int b = a + n - 1; cout << "[" << a << ", " << b << "]"; } int main() { int n = 3 ; showRange(n); }

[122, 124]

Advertisements