- Given two integers
num1
andnum2
, return the sum of the two integers.
- Input: num1 = 12, num2 = 5
- Output: 17
- Explanatio: num1 is 12, num2 is 5, and their sum is 12 + 5 = 17, so 17 is returned.
-100<= num1, num2 <= 100
- You are given a positive integer
n
. Each digit ofn
has a sign according to the following rules:- The most significant digit is assigned a positive sign.
- Each other digit has an opposite sign to its adjacent digits.
- Return the sum all digits with their corresponding sign.
- Input: n = 521
- Output: 4
- Explanation: (+5) + (-2) + (+1) = 4
- Input: n = 111
- Output: 1
- Explanation: (+1) + (-1) + (+1) = 1.
1<= n <= 10⁹