You are viewing a single comment's thread. Return to all comments →
Set<Integer> socks = new HashSet<>(); int result = 0; for(int val : ar) { if(socks.remove(val)){ result++; } else { socks.add(val); } } return result;
This is basically the same but a bit simpler as remove would dothe "contains" part as well.
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 →
This is basically the same but a bit simpler as remove would dothe "contains" part as well.