Skip to content

Latest commit

 

History

History

April_25

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

2235. Add Two Integers

  • Given two integers num1 and num2, return the sum of the two integers.
Example:
  • 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.
Constraints:
  • -100<= num1, num2 <= 100

Solution:

2544. Alternating Digit Sum

  • You are given a positive integer n. Each digit of n 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.
Example 1:
  • Input: n = 521
  • Output: 4
  • Explanation: (+5) + (-2) + (+1) = 4
Example 2:
  • Input: n = 111
  • Output: 1
  • Explanation: (+1) + (-1) + (+1) = 1.
Constraints:
  • 1<= n <= 10⁹

Solution: