solution to remove duplicate values from an array