Easy · Math
Sum of Digits
Given an integer n, return the sum of its decimal digits, ignoring the sign (for example 12345 → 15 and −908 → 9 + 0 + 8 = 17).
Examples
Example 1
n = 12345Output: sum = 15
Example 2
n = -908Output: sum = 17
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.