You are viewing a single comment's thread. Return to all comments →
Why check contains when add does the same thing, returning false when the item is already in the set? That makes it a lot simpler:
contains
add
false
if (!colors.add(c[i])) { pairs++; colors.remove(c[i]); }
Seems like cookies are disabled on this browser, please enable them to open this website
Sales by Match
You are viewing a single comment's thread. Return to all comments →
Why check
contains
whenadd
does the same thing, returningfalse
when the item is already in the set? That makes it a lot simpler: