Algorithm · Amazon · Medium
You are given an integer array nums and a positive integer k. Your task is to assemble as many distinct numbers as possible from the array into a sequence, called a chain. The order of the elements in the chain is up to you, but for every pair of neighboring elements in the chain, the absolute difference must be no larger than k. Notes on usage: You may not use the same integer more than once, even if it appears multiple times in nums. Two copies of the same value do not…
Checking your access…