Adding the elements to a set is correct but why it is showing wrong