Suppose I have a list, for example: list = {1, 3, 5, 5, 12, 12, 6, 11, 7, 7, 9, 10, 2, 2, 4};
and list of duplicates positions in the list positions = {3, 9};
, that should not be touched by DeleteDuplicates
. Other duplicates should be deleted. (the desired result should be
{1, 3, 5, 5, 12, 6, 11, 7, 7, 9, 10, 2, 4}
Also, the elements defined by positions (for example 5) should not be deleted even if there are many of them in the list. How can this be done in a most efficient way?
list={1,2,3,3,4,3}
andposition={3}
, what's your expected output? $\endgroup${1, 3, 5, 5, 12, 5, 5, 11, 7, 7, 9, 10, 2, 2, 4}
? is it{1, 3, 5, 5, 12, 5, 11, 7, 7, 9, 10, 2, 4}
? $\endgroup${1, 3, 5, 5, 12, 5, 5, 11, 7, 7, 9, 10, 2, 4}
$\endgroup$DeleteDuplicates
should not touch the elements at the given positions. Please include that part in the question. $\endgroup$