✅C++ | ✅Merging & Counting | ✅Efficient Approach
Intuition\nWe need to find total number of non-overlapping range i.e. total and possible ways will be 2^(total).\n\n# Code\n\nclass Solution \n{\npublic:\n    i
# Intuition\nWe need to find total number of non-overlapping range i.e. total and possible ways will be 2^(total).\n\n# Code\n```\nclass Solution \n{\npublic:\n    int countWays(vector<vector<int>>& ranges) \n    {\n        sort(ranges.begin(), ranges.end());\n        int total = 1, maxi_range=ranges[0][1];\n        for(int i=1; i<ranges.size(); i++)\n        {\n            if(ranges[i][0] > maxi_range) total++;\n            maxi_range = max(maxi_range, ranges[i][1]);\n        }\n        \n        int ways=1, mod=1e9+7;\n        while(total--)\n        {\n            ways = (ways*2)%mod;\n        }\n        return ways;\n    }\n};\n```\n# Please upvote if you like this approach :)
['Array', 'Sorting', 'Counting', 'C++']