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) fits within the execution time limit.
Function
mostFrequentReducedDigit(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.
Example 3
readings = [3,12,23,32,0]return = 5The readings reduce to [3,3,5,5,0]. Digits 3 and 5 each occur twice, so the tie is resolved in favor of the higher digit, 5.
Constraints
- Every value in
readingsis a non-negative integer.
More Airbnb problems
- Rectangle Fit QueriesOA · Seen Jul 2026
- Robot Final DirectionOA · Seen Jul 2026
- Robot Inventory TrackingOA · Seen Jul 2026
- Parse Query StringPHONE SCREEN · Seen May 2026
- Print Sentences as TablePHONE SCREEN · Seen May 2026
- Minimum Eating SpeedSeen Mar 2024
- Minimum MovesSeen Dec 2022
- Donut ChallengeSeen Dec 2022