Negate a number using addition operator


Given a number X, flip it to -X.

Time complexity :

O ( X )

Logic :

The negation can be implemented by adding -1, X times.

Solution :

You may also like...

Leave a Reply

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

Show Buttons
Hide Buttons