socks[i] is the color of sock i. The number of socks is even.
Can all the socks be split into pairs so that both socks in every pair share a color and every sock is in exactly one pair? Return True if so, and False otherwise.socks=[5, 2, 5, 2, 2, 2] → True
The pairs are (5, 5), (2, 2) and (2, 2): four socks of color 2 make two pairs.
socks=[7, 7, 3, 1] → False
The socks of colors 3 and 1 are left without a match.
socks=[9, 9] → True
socks=[5, 2, 5, 2, 2, 2]
True
Run checks the first 3 tests in your browser. Submit checks all 86 tests on the server, hidden ones included.