Simple Merge Interval || Easy to understand
THE ONLY NEW THING IN THIS QUESTION\n To group \'n\' items into 2 groups, there are (2 ^ n) possible ways \n \n \n  class Solution {\npublic:\n   int MOD = 1000
**THE ONLY NEW THING IN THIS QUESTION**\n To group \'n\' items into 2 groups, there are (2 ^ n) possible ways \n \n ```\n  class Solution {\npublic:\n   int MOD = 1000000007;\n   int calcPower(int base, int power)  //modulo exponentation\n   {\n       long long ans = 1;\n       while(power > 0)\n       {\n           if (power % 2 != 0) \n           {\n               ans = (ans * (long long)base) % MOD; \n               power--; \n           }\n           else \n           {\n               power = power / 2;\n               base = (base * (long long)base) % MOD;\n           }\n       }\n       return (int)ans;\n   }\n   int countWays(vector<vector<int>>& ranges) \n   {\n       int n = ranges.size();\n       sort(ranges.begin(), ranges.end());\n       //===================================================================================\n       //SAME PROCESS AS MERGE INTERVALS QUESTION\n       int prevLow = ranges[0][0], prevHigh = ranges[0][1];\n       int count = 1;  //count of non overlapping ranges \n       for (int i = 1; i < n; i++)\n       {\n           if (ranges[i][0] >= prevLow && ranges[i][0] <= prevHigh)  \n           {\n               //This means that the current interval overlaps with the previous interval \n               //so just merge it then .... update the new interval\n               prevHigh = max(prevHigh, ranges[i][1]);\n           }\n           else\n           {\n               prevLow = ranges[i][0];\n               prevHigh = ranges[i][1];\n               count++;\n           }\n       }\n       //==========================================================================================\n       return calcPower(2, count);\n   }\n};\n ```\n
['C', 'C++']