DEV Community

Discussion on: Javascript Sock Merchant Challenge - Solution 1

Collapse
 
kurisutofu profile image
kurisutofu • Edited

Could we add 0.5 to avoid reiteration and round up when getting the value for a specific color?

Collapse
 
adyngom profile image
Ady Ngom

Reiteration is prevented by skipping to 2 indexes down if a match is found. I’m not clear on how 0.5 will help here since we are looking at full pairs values

Thread Thread
 
kurisutofu profile image
kurisutofu

Yes, you're right. I somehow didn't notice you were using i++ and i+=1.
Sorry.

The 0.5 comment was regarding Bavesh's step 4, sorry I was not clear.