C++||Most Easy Solution Using Concept Of Merge Intervals
Basically we have to return pow(2,n) where n is size of final array containg all the merged intervals\n\ntypedef long long ll;\nclass Solution {\npublic:\n    i
**Basically we have to return pow(2,n) where n is size of final array containg all the merged intervals**\n```\ntypedef long long ll;\nclass Solution {\npublic:\n    int mod=1e9+7;\n ll power(int x, unsigned int y)\n{\n    ll temp;\n    if (y == 0)\n        return 1;\n    temp = power(x, y / 2)%mod;\n    if (y % 2 == 0)\n        return ((temp%mod) * (temp%mod))%mod;\n    else\n        return ((x%mod) *(temp%mod) * (temp%mod))%mod;\n}\n    int countWays(vector<vector<int>>& ranges) {\n        sort(ranges.begin(),ranges.end());\n        vector<vector<int>> ans;\n        int n=ranges.size();\n        for(int i=0;i<n;i++)\n        {\n            if(ans.size()==0)\n            {\n                ans.push_back(ranges[i]);\n            }\n            else\n            {\n                vector<int> &v=ans.back();\n                int s=v[0],e=v[1];\n                if(ranges[i][0]<=v[1])\n                {\n                    v[1]=max(e,ranges[i][1]);\n                }\n                else\n                    ans.push_back(ranges[i]);\n            }\n        }\n        int n1=ans.size();\n        return power(2,n1)%mod;\n    }\n};\n```
[]