How I solved "Sales by Match" on HackerRank
Sales by Match Problem Description
There is a large pile of socks that must be paired by color. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are.
Example
There is one pa...
tob.hashnode.dev4 min read
Biplob Manna
I do interesting things when I get bored!
Nice article!
If I could provide some suggestion here, in the second for loop, all those lines of
ifconditions andisEven()function call can be reduced topairs += counts[item] / 2 | 0to get the integer division value.for (const item in counts) pairs += counts[item] / 2 | 0;