#104

Sum of Digits

EASYMathpython

Problem Description

A data processing pipeline transforms raw numeric identifiers into digit-sum checksums for partitioning and validation. Given an array of integers `nums`, return a new array where each element is the sum of digits of the corresponding number. **Task:** For each number in `nums`, compute the sum of its individual digits (use absolute value for negatives) and return the results as a list. **Key Rules:** - Handle negative numbers by summing digits of their absolute value. - Compute digit sums in a single pass without nested loops. **Constraints:** - `0 <= len(nums) <= 100,000` - `-10^9 <= nums[i] <= 10^9`

Topics

arraystring

Asked at Companies

walmart

Solve This Problem

Sign up to access the interactive code editor, run test cases, view the editorial, and get AI-powered feedback on your solution.

Start Solving →