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
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.