Daily challenge for 2026-08-05
582. Alternating Sign Digit Sum
Given a positive integer n, return the sum of its digits with alternating signs, starting with a positive sign for the most significant digit, followed by a negative sign for the next, and so on.
Example:
Input: n = 521
Output: 4
Explanation: The digits are 5, 2, and 1. The alternating sum is +5 - 2 + 1 = 4.
Run this challenge interactively in Python or JavaScript when the app loads.