Count non-overlapping groups of intervals [C++]
Intuition\n Describe your first thoughts on how to solve this problem. \n group all the overlapping intervals and count them as 1 as 1 group.\n to do this sort 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n* group all the overlapping intervals and count them as 1 as 1 group.\n* to do this sort the array on the bases of start and end of intervals.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n* If we have n groups of intervals and we want to categorise them in either of a group. therefore for each group of intervals we have 2 cases.\n* => that we have $${2^n}$$ ways of arranging these groups.\n# Complexity\n- Time complexity: O(n +log n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n#define ll long long\nclass Solution {\npublic:\n    \n    const int M = 1e9 + 7;\n    long long int powxy(long long int x, long long int y) {\n        if (y == 0) return 1;\n        if (y%2 == 1) return (x*powxy(x, y-1))%M;\n        long long int t = powxy(x, y/2);\n        return (t*t)%M;\n    }\n    \n    int countWays(vector<vector<int>>& ranges) \n    {\n        int n=ranges.size();\n        auto mycmp=[&]( vector<int>&a,  vector<int>&b){\n           if(a[0]!=b[0])\n               return a[0]<b[0];\n            return a[1]<b[1];\n        };\n        sort(begin(ranges),end(ranges),mycmp);  \n        \n        int groups=0,maxi=-1;\n        for(int i=0;i<n;i++)\n        {\n            if(maxi<ranges[i][0])\n            {\n                groups++;\n            }\n            maxi=max(maxi,ranges[i][1]);\n        }\n        \n        return powxy(1LL*2,1LL*groups);\n    }\n};\n```
['Math', 'Sorting', 'C++']