Update Duplicates in an array.cpp