1class Solution:2def partitionArray(self, nums: List[int], k: int) -> int:3nums.sort()4ans = 15# To keep track of starting element of each subsequence6start = nums[0]78for i in range(1, len(nums)):9diff = nums[i] - start10if diff > k:11# If difference of starting and current element of subsequence is greater12# than K, then only start new subsequence13ans += 114start = nums[i]1516return ans