Problem · Array
Most Frequent Reduced Digit
Learn this problemProblem statement
You are working with data collected from various sensors. Given an array of non-negative integers readings, repeatedly replace each value with the sum of its decimal digits until every value is a single digit.
Return the most frequent digit in the final transformed array. If several digits have the same highest frequency, return the highest such digit.
A solution with time complexity no worse than O(readings.length^2) will fit within the execution time limit.
Function
solution(readings: int[]) → intExamples
Example 1
readings = [123,456,789,101]return = 6123becomes1 + 2 + 3 = 6.456becomes4 + 5 + 6 = 15, then1 + 5 = 6.789becomes7 + 8 + 9 = 24, then2 + 4 = 6.101becomes1 + 0 + 1 = 2.
The final array is [6,6,6,2], so the most frequent digit is 6.
Example 2
readings = [6]return = 6The reading 6 is already a single digit, so the final array remains [6] and the result is 6.
Constraints
- Every value in
readingsis a non-negative integer.
More Meta problems
- Count Fully Used BatteriesOA · Seen Jul 2026
- Count Key ChangesOA · Seen Jul 2026
- Minimum Operations for a Stepwise SequenceOA · Seen Jul 2026
- Plan a Minimum-Cost Round TripONSITE INTERVIEW · Seen Jul 2026
- Merge Three Sorted ArraysPHONE SCREEN · Seen May 2026
- Highest Rating Price RatioOA · Seen Mar 2026
- Diagonal Traverse (for E4 ;)PHONE SCREEN · Seen Mar 2025
- Find Peak ElementPHONE SCREEN · Seen Mar 2025