In your test case, which is the same I wrote about, there are two complete pairs: one pair of type 1, and one pair of type 2. There is a remainder sock of types 1 and 3. And that’s what the algorithm correctly outputs: 2 pairs of socks.

Where does your confusion lie?

--

Always learning.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store