We’re preparing your current view and syncing the latest data.
Find max length of valid subsequence I
gfgGiven two integer arrays nums and threshold, find the maximum length of a subsequence of nums such that the difference between the maximum and minimum elements in the subsequence is less than or equal to threshold.
Two lines: first line contains the integer array nums, second line contains the integer threshold.
A single integer denoting the maximum length of the valid subsequence.
1 <= nums.length <= 10^5, 0 <= nums[i] <= 10^9, 0 <= threshold <= 10^9