algorithms EPICh6 kotlin

Problem 6.2 from EPI -> Increment an arbitrary precision decimal number

This one is very cool, what if you have to implement a plus one operation to a very large number, in most languages you have that like in Java there is a BigInteger, but what if you have to write it in c++? Then you would implement your own addition, so the problem requires to implement +1 operations, which can be easily transformed into two number addition, check out the solution here.
I have also added a solution for the variation of problem 6.2. The variation requires addition of two strings that contain binary representation of two numbers. The solution is not that difficult, there is this hard coded version and a more elegant version with bitwise operations, check out the solution here.

Leave a Reply

Your email address will not be published. Required fields are marked *