C++ || BINARY SEARCH || SORT || EASY TO UNDERSTAND
Intuition\n\nhere we need to find all subsequece.\nso find biggest element for (v[i]+x)<=target\nall element between [v[i] to x] possible ans v[i] must be inclu
# Intuition\n\nhere we need to find all subsequece.\nso find biggest element for (v[i]+x)<=target\nall element between [v[i] to x] possible ans v[i] must be included in subsequence.\n\n# Approach\nSORT ARRAY\nfind upper bound of target-v[i]. let\'s upperbound\'s index equal to x\nif(x<i)break;\nelse increment ans by (1LL<(x-i-1)) \n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nCONSTANT SPACE\n\n# Code\n```\n//IF ANY SUGGETION INFORM ME \n//AND UPVOTE THIS SOLUTION\nclass Solution {\npublic:\n    int po(int x){\n        int y = 1, mod = 1e9+7,z = 2;\n        while(x){\n            if(x&1){\n                y = (y*1LL*z)%mod;\n            }\n            x >>= 1;\n            z = (z*1LL*z)%mod;\n        }\n        return y;\n    }\n    int numSubseq(vector<int>& nums, int target) {\n        int mod = 1e9+7;\n        sort(nums.begin(),nums.end());\n        for(auto &i: nums)cout<<i<<" ";\n        int ans = 0;\n        int i,x,n=nums.size();\n        for(i = 0; i < n; i++){\n            x = upper_bound(nums.begin(),nums.end(),target-nums[i])-nums.begin();//find an element x index for that v[i]+x>target\n            \n            if(x-i-1<0)break;\n            ans = (ans + po(x-i-1)%mod)%mod;//get all possible ans for an sorted subarray\n        }\n        return ans;\n    }\n};\n```
['Binary Search', 'Sorting', 'C++']