Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

Negate a number using addition operator

Problem:

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 *