• 0

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 :