1498. Number of Subsequences That Satisfy the Given Sum Condition
class Solution {\n    int power(int b) {\n        long long ans = 1, k = 2, mod = 1e9 + 7;\n        while(b) {\n            if(b % 2) ans = (ans * k) % mod;\n  
class Solution {\n    int power(int b) {\n        long long ans = 1, k = 2, mod = 1e9 + 7;\n        while(b) {\n            if(b % 2) ans = (ans * k) % mod;\n            b /= 2;\n            k = (k * k) % mod;\n        }\n        return ans;\n    }\npublic:\n    int numSubseq(vector<int>& nums, int target) {\n        long long n = nums.size(), ans = 0, mod = 1e9 + 7;\n        sort(nums.begin(), nums.end());\n\n        for(int i=0; i<n; i++) {\n            int pos = upper_bound(nums.begin() + i, nums.end(), target - nums[i]) - nums.begin() - 1;\n            if(pos - i >= 0) ans = (ans + power(pos - i))% mod;\n        }\n        return ans;\n    }\n};
['C']