Count Digit Holes
Updated
Problem statement
Certain decimal digits contain closed loops, or holes, when written:
- Digits
0,4,6, and9each contain one hole. - Digit
8contains two holes. - Digits
1,2,3,5, and7contain no holes.
Given an integer number, return the total number of holes across all of its digits.
Function
countDigitHoles(number: int) → intExamples
Example 1
number = 649578return = 5Digits 6, 4, and 9 contribute one hole each, while digit 8 contributes two. The total is 5.
Example 2
number = 123return = 0None of the digits 1, 2, or 3 contains a hole.
Example 3
number = 1000000000return = 9The leading 1 contributes no holes, and each of the nine zeroes contributes one.
Constraints
1 <= number <= 10^9.
More IBM Online Assessment questions
- Missing IntervalsOA · Seen Nov 2026
- Count Peaks and ValleysOA · Seen Nov 2026
- Last Object Exit TimeOA · Seen Nov 2026
- Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
- Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
- Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
- Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
- Tree Pythagorean TriplesOA · Seen Oct 2026
- Minimum Power-of-Two Removal OperationsOA · Seen Oct 2026
- Maximum Compatible Time WindowsOA · Seen Oct 2026
Similar questions at other companies
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
- Costliest ChocolateRippling · OARippling interview questions
- Distinct Chapters Missed During a Cyclic AbsenceVisa · OAVisa interview questions
- Count Palindromic Base RepresentationsSEDEMAC · OA
- Reduce a Number to One DigitAccenture · OAAccenture interview questions
- Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
- Calculate the Half SpreadMillennium · OAMillennium interview questions
- Product Minus Sum of DigitsTikTok · OATikTok interview questions
- Progressive Tax CalculatorInteractive Brokers · OA