Easy approach | C++ solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \ncount the number of dif
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\ncount the number of different distinct groups that can go in either group1 or group2.Then, we find the number of ways in which we can divide the groups into 2. \n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int power(int count)\n    {\n        if(count==1)\n        return 2;\n        long long p=power(count/2);\n        p=p%1000000007;\n        p*=power(count/2);\n        p=p%1000000007;\n        if(count%2!=0)\n        p*=2;\n        p=p%1000000007;\n        return p;\n    }\n    int countWays(vector<vector<int>>& ranges) {\n        sort(ranges.begin(),ranges.end(),[](vector<int>&a,vector<int>&b)\n             {\n                return a[0]<b[0]; \n             });\n        int count=1;int minstart=ranges[0][0];int maxend=ranges[0][1];\n        for(int i=1;i<ranges.size();i++)\n        {\n            int start=ranges[i][0];\n            int end=ranges[i][1];\n            if(start>maxend) \n            {\n                minstart=start;\n                maxend=end;\n                count++;\n            }\n            else{\n                minstart=min(minstart,start);\n                maxend=max(maxend,end);\n            }\n            \n        }\n        int c=power(count);\n        return c;\n    }\n};\n```
['Array', 'Sorting', 'C++']