int[] nums = { 4, 3, 2, 5, 6, 7, 3, 4, 2, 1 }; // Using HashSet instead of LinkedHashSet if order doesn't matter.