C#, and TypeScript Solution 🔥🚀 with approach. ❇️✅
\u2B06\uFE0FLike|\uD83C\uDFAFShare|\u2B50Favourite\n\n\n\n# Complexity\n- Time complexity:\nO(n log n)\n\n- Space complexity:\n O(n)\n\ncsharp []\npublic class 
# \u2B06\uFE0FLike|\uD83C\uDFAFShare|\u2B50Favourite\n\n![image.png](https://assets.leetcode.com/users/images/fd040c94-9dd5-4cd1-858d-5147082a69e7_1683351025.6271682.png)\n\n# Complexity\n- Time complexity:\nO(n log n)\n\n- Space complexity:\n O(n)\n\n```csharp []\npublic class Solution {\n    public int NumSubseq(int[] nums, int target) {\n        // Sort the array in non-decreasing order\n        Array.Sort(nums);\n\n        // Initialize variables\n        int mod = 1000000007;\n        int n = nums.Length;\n        int ans = 0;\n\n        // Calculate powers of 2 modulo mod\n        int[] pow2 = new int[n];\n        pow2[0] = 1;\n        for (int i = 1; i < n; i++) {\n            pow2[i] = (pow2[i - 1] * 2) % mod;\n        }\n\n        // Use two pointers to find subsequences\n        int left = 0, right = n - 1;\n        while (left <= right) {\n            // If the sum of the minimum and maximum values is less than or equal to target,\n            // add the number of subsequences of length (right - left) to the answer\n            if (nums[left] + nums[right] <= target) {\n                ans = (ans + pow2[right - left]) % mod;\n                left++;\n            }\n            // Otherwise, move the right pointer to the left\n            else {\n                right--;\n            }\n        }\n\n        return ans;\n    }\n}\n```\n```typescript []\nfunction numSubseq(nums: number[], target: number): number {\n    nums.sort((a, b) => a - b); // sort array in non-decreasing order\n\n    const mod = 1e9 + 7;\n    const n = nums.length;\n    let ans = 0;\n\n    // calculate powers of 2 modulo mod\n    const pow2: number[] = new Array(n);\n    pow2[0] = 1;\n    for (let i = 1; i < n; i++) {\n        pow2[i] = (pow2[i - 1] * 2) % mod;\n    }\n\n    // use two pointers to find subsequences\n    let left = 0, right = n - 1;\n    while (left <= right) {\n        // if the sum of the minimum and maximum values is less than or equal to target,\n        // add the number of subsequences of length (right - left) to the answer\n        if (nums[left] + nums[right] <= target) {\n            ans = (ans + pow2[right - left]) % mod;\n            left++;\n        }\n        // otherwise, move the right pointer to the left\n        else {\n            right--;\n        }\n    }\n\n    return ans;\n};\n```
['Array', 'Two Pointers', 'Sorting', 'TypeScript', 'C#']