EASY C++ SOLUTION (BEGINNER LEVEL UNDERSTANDING)
Intuition\nJUST FIND THE OVERLAPPING GROUPS IN THE GIVEN ARRAY OF SEGMENT AS THEY CAN\'T BE IN DIFFERRNT GROUPS THEN EVERY GROUPS OF SEGMENT CAN BE IN EITHER OF
# Intuition\nJUST FIND THE OVERLAPPING GROUPS IN THE GIVEN ARRAY OF SEGMENT AS THEY CAN\'T BE IN DIFFERRNT GROUPS THEN EVERY GROUPS OF SEGMENT CAN BE IN EITHER OF TWO GROUPS SO:\n\nANS = POW(2, NO. OF GROUPS) % 1e9+7;\n\n# Approach\nCOUNT OF OVERLAPPPING SEGMENTS \n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(N)\n\n# Code\n```\nclass Solution {\npublic:\n    \n    #define ll long long int \n    ll mod = 1e9+7;\n    \n    int  binpow(ll  a, ll  b)\n{\n    ll  res = 1;\n    while (b > 0)\n    {\n        if (b & 1)\n            res = (res * a)%mod;\n        a = (a * a)%mod;\n        b >>= 1;\n    }\n    return res%mod;\n}\n    int countWays(vector<vector<int>>& arr) {\n   int n=arr.size();\n        int mod = 1e9+7;\n        sort(arr.begin(),arr.end());\n        ll ans=1;\n    int mxx = arr[0][1];\n        for(int i=1;i<n;i++){\n            ll yy   = arr[i][0];\n            if(yy<=mxx){\n                mxx=max(mxx,arr[i][1]);\n                continue;\n            }\n            else {\n                mxx  = arr[i][1];\n                ans++;\n            }    \n            \n        }\n        ll val = binpow(2,ans)%mod;\n        return (int)val;\n        \n\n        \n    }\n};\n```
['Array', 'Sorting', 'C++']