You're given an integer vector A, a Min scalar and a Max scalar. You can assume all elements in A are in [Min,Max] range, and numel(A)<=Max-Min+1.
Your function should output also an integer vector B, whose elements are also in [Min,Max] range, and whose numel is the same as A (numel(B)==numel(A), i.e., lossless). What is different is that your B must not have duplicate values (i.e., deduplication).
There may be more than one possible Bs meeting the conditions above. You need to give the "best" one. The "best" is defined as the B making Error=sum(abs(sort(A)-sort(B))) smallest (i.e. optimal) among all possible Bs.

Solution Stats

4 Solutions

3 Solvers

Last Solution submitted on Dec 08, 2025

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...