nums
in non-decreasing order.count
to 1, which represents the minimum number of subsequences needed.min_value
to the first element of the sorted array, which is the minimum value of the first subsequence.num
, check if num - min_value
is greater than k
.
b. If it is, increment count
and update min_value
to num
because a new subsequence must start.count
as the minimum number of subsequences needed.