Fully explained code C++
Intuition\nThe ranges are merging into each other so sorting will give the required solution\n\n# Code\n\nclass Solution {\npublic:\n    int countWays(vector<ve
# Intuition\nThe ranges are merging into each other so sorting will give the required solution\n\n# Code\n```\nclass Solution {\npublic:\n    int countWays(vector<vector<int>>& ranges) {\n     vector<pair<int,int>>v;\n        // creating a vector pair in order to sort the range groups\n        for(auto& i:ranges){\n            v.push_back({i[0],i[1]});\n        }\n        sort(v.begin(),v.end());\n        int la=-1,ans=0;\n        // maintaing the upper bound so that we can check whether this range \n        // is independent or inclusive of some previous range\n        // here we are creating sets of ranges which will be together\n        for(auto& i:v){\n            if(i.first>la){\n                ans++;\n                la=i.second;\n            }\n            else la=max(la,i.second);\n        }\n        // calculating power via loop to avoid any overflows\n        // calculating 2 to the power ans as and every set will have two options to go in either group one or two hence every set will have two choices so total ways equals 2 to the power no of sets\n        int a=1;\n        for(int i=0;i<ans;i++){\n            a=(a*2)%1000000007;\n        }\n        return a;\n    }\n};\n```
['C++']