DEV Community

Discussion on: Algorithms Problem Solving: Reduce to zero

Collapse
 
theshadowfax profile image
Srujan Kumar

Hey imagine this solution as travelling a series if bits where travelling has a cost, for example travelling from 0 to 1 and 0 to 0 will cost you "1" and travelling from 1 to 1 will cost you "2" and travelling from 1 to 0 will also cost you "2" and if the last bit is 1 then add "1"
So 10110 will cost you 7.

Thread Thread
 
thejoezack profile image
Joe Zack

Ah ok, very cool! Thanks for explaining!