Problem · Math
Sum Digits Until One
Given a list, for each element in the list, repeatedly sum the digits until it becomes a single-digit number. Then return the mode of the resulting numbers.
For example:
['1234', '24', '33'] → ['10', '6', '6'] → ['1', '6', '6']
So the result is 6.
Complete the function sumDigitsUntilOne in the editor.
sumDigitsUntilOne has the following parameter:
List: a list of strings representing numbersnumbers
Returns
int: the mode of the single-digit numbers obtained by repeatedly summing the digits
Examples
01 · Example 1
numbers = ["1234", "24", "33"] return = 6
The process of summing the digits repeatedly until a single-digit number is obtained is as follows:
- 1234 → 1+2+3+4 = 10 → 1+0 = 1
- 24 → 2+4 = 6
- 33 → 3+3 = 6
The resulting single-digit numbers are 1, 6, and 6. The mode of these numbers is 6.
More Capital One problems
- Count House Segments After DestructionOA · Seen May 2026
- Count Numbers with Even Number of DigitsOA · Seen May 2026
- Laser Robot Safe PathOA · Seen May 2026
- Longest Same-Character SubstringOA · Seen May 2026
- Cyclic Shift to Strictly Descending ArrayOA · Seen May 2026
- Dynamic Wall Building and Range QueryOA · Seen May 2026
- Queue Check-in Simulation with Capacity LimitOA · Seen May 2026
- Get Function Execution TimeSeen Jan 2025
public int sumDigitsUntilOne(List<String> numbers) {
// write your code here
}
numbers["1234", "24", "33"]
expected6
sign in to submit