Difference Between Element Sum and Digit Sum of an Array Problem

Difference Between Element Sum and Digit Sum of an Array Problem — ExecCode Easy DSA Practice

Solve the Difference Between Element Sum and Digit Sum of an Array problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a positive integer array nums. Your task is to compute the required answer and return the absolute difference between the element sum and digit sum of nums. The element sum is the sum of all the elements in nums. - The digit sum is the sum of all the digits (not necessarily distinct) that appear in nums. Note that the absolute difference between two integers x and y is defined as |x - y|.

Examples

Input {"nums": [1, 15, 6, 3]}; Output 9. Input {"nums": [1, 2, 3, 4]}; Output 0

Constraints

1 <= nums.length <= 2000 1 <= nums[i] <= 2000

Practice Difference Between Element Sum and Digit Sum of an Array free on ExecCode. Browse DSA problems, topic map, and placement guides.