c++ easy solution✅
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nsimilar to leecode prob
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nsimilar to leecode problem [Merge Intervals](https://leetcode.com/problems/merge-intervals/)\nstep 1: count the number of intervals which are overlapping and count all of them as a single interval\nstep 2: if there are n distinct intervals and we have to divide it into two boxes and each box has 2 possibilities whether to take an element or not take\nso no. of ways=2^n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(nlogn)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int countWays(vector<vector<int>>& ranges) {\n        sort(ranges.begin(),ranges.end());\n        // for(auto i:ranges)cout<<i[0]<<" "<<i[1]<<endl;\n        vector<int>prev=ranges[0];\n        int cnt=1;\n        for(auto i:ranges){\n            if(prev[1]>=i[0]){\n                prev[0]=min(prev[0],i[0]);\n                prev[1]=max(prev[1],i[1]);\n            }else {\n                cnt++;\n                prev[0]=min(prev[0],i[0]);\n                prev[1]=max(prev[1],i[1]);\n            }\n        }\n        // cout<<cnt;\n        int ans=1;\n        int mod=1e9+7;\n        for(int i=0;i<cnt;i++){\n            ans=(ans*2)%mod;\n        }\n        return ans%mod;\n    }\n};\n```
['C++']