Two Sum,Python solution, explained, O(nlogn)
1.This problem is a manipulation of Two sum problem.\n\t2. In this problem, order of numbers of a subsequence doesn\'t matter as we just have to consider max an
1.This problem is a manipulation of Two sum problem.\n\t2. In this problem, order of numbers of a subsequence doesn\'t matter as we just have to consider max and min of subsequence.Therefore, a subsequence from i to j in original array is equivalent to array having same elements and same minimum and maximum value. For e.g  consider, nums = [3,7,6,5] and target = 10.For eg, In this a subsequence [3,7,6] is equivalent to subsequence [3,6,7] of [3,5,6,7]. Therefore, result of nums is equal to result of sorted[nums].\n3. For each index "i" in sorted_nums, find maximum "j" such that sorted_nums[i] + sorted_nums[j] <= target and j >= i.\n4.  From i+1 to j, we can either pick or leave each element.\n5.  Therefore, res += 2**(j-i)\n```\n       \n\t    res = 0\n        end = len(nums)-1\n        nums.sort()\n        for i in range(len(nums)):\n            while nums[i] + nums[end] > target:\n                if end > i:\n                    end = end-1\n                else:\n                    return res % (10**(9)+7)\n            res += pow(2, end - i)\n        return res % (10**(9)+7)\n```\nUpvote if you like the solution :)
['Sliding Window', 'Python3']