C++ Very Simple Solution - Sorting, Two Pointers, Sliding Window, Memoization - Time : O(n*logn)
Intuition\n Describe your first thoughts on how to solve this problem. \n1. Problem is to find subsequences. So, Order is not important, I can sort it.\n2. Two 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1. Problem is to find **subsequences**. So, Order is not important, I can **sort** it.\n2. **Two pointer approach**. Because we need minimum and maximum in that subsequence, Left pointer will be pointing minimum and right pointer pointing maximum.\n3. **Sliding window approach** is used to find the number of subsequences between left and right pointer as the window size changes as the execution processes.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Sort the vector.\n2. Initialize left pointer l = 0 and right pointer r = nums.size() - 1.\n3. Check if nums[l] + nums[r] <= target. Then find the number of subsequences possible from l to r.\n4. We use **Memoization** to precompute all the 2 powers less than max size into a vector. Max size is r-l+1 max value which is nums.size().\n5. If the nums[l] + nums[r] > target then we should choose lesser maximum value so decrement r.\n6. Continue until l > r.\n7. Since the numbers can overflow, mod with 1000000007.\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# CPP Code\n```\nclass Solution {\npublic:\n    int mod = 1e9 + 7;\n    int numSubseq(vector<int>& nums, int target) {\n        sort(nums.begin(), nums.end());\n        int res = 0, n = nums.size(), l = 0, r = n - 1;\n        vector<int> pows(n, 1);\n        // <<1 is a left shift operator which is equivalent to 2*num\n        // Bit shift is comparitively faster than multiplication\n        for (int i = 1 ; i < n ; ++i)\n            pows[i] = (pows[i - 1]<<1) % mod;\n        while (l <= r) {\n            if (nums[l] + nums[r] <= target) {\n                res = (res + pows[r - l]) % mod;\n                l++;                \n            } else {\n                r--;\n            }\n        }\n        return res;\n    }\n};\n```\n\n---\n\nGo through the intuition and approach to better understand the solution. Feel free to comment your doubts or findings. \n\n<h2 align="center">Please Upvote if you find this useful. Thank you.</h2>
['Two Pointers', 'Memoization', 'Sliding Window', 'Sorting', 'C++']