STACK MERGE INTERVAL || C++
\nclass Solution {\npublic:\n    bool static cmp(vector<int> &a,vector<int> &b){\n        if(a[1]==b[1])return a[0]<b[0];\n        return a[1]<b[1];\n    }\n   
```\nclass Solution {\npublic:\n    bool static cmp(vector<int> &a,vector<int> &b){\n        if(a[1]==b[1])return a[0]<b[0];\n        return a[1]<b[1];\n    }\n    int countWays(vector<vector<int>>& v) {\n        sort(v.begin(),v.end(),cmp);\n        stack<vector<int>> s;\n        // int mn;\n        s.push(v[0]);\n        for(int i = 1; i < v.size(); i++){\n            while(!s.empty()&&s.top()[1]>=v[i][0]){\n                s.pop();\n            }\n            if(s.empty()){\n                s.push(v[i]);\n            }else if(s.top()[1]<v[i][0]){\n                s.push(v[i]);\n            }else{\n                s.top()[1] = v[i][1];\n            }\n            \n        }\n        int mod = 1e9+7;\n        int ans = 1;\n        while(s.size()){\n            ans = (ans*2)%mod;\n            s.pop();\n        }\n        return ans;\n    }\n};\n```
['Math', 'Stack', 'C', 'Sorting', 'C++']