Sum Even Minus Odd Digits

EasyMath

Description

Given an integer n, compute the sum of its even digits minus the sum of its odd digits (using the absolute value of n).

Examples

Input:n = 1234
Output:2
Explanation:

Even 2+4=6, odd 1+3=4, diff=2.

Input:n = 9
Output:-9
Explanation:

Only odd digit 9.

Input:n = 2468
Output:20
Explanation:

All digits even, sum=20.

Constraints

  • -10¹⁸ ≤ n ≤ 10¹⁸

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.