FastPrepCount Digit Holes
Problems/Count Digit Holes

Count Digit Holes

IBM logoIBM● EasyFULLTIMENEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an IBM online assessment. The report does not give the function signature. Our version is about 99% the same as the reported question.

Certain decimal digits contain closed loops, or holes, when written:

  • Digits 0, 4, 6, and 9 each contain one hole.
  • Digit 8 contains two holes.
  • Digits 1, 2, 3, 5, and 7 contain no holes.

Given an integer number, return the total number of holes across all of its digits.

Function

countDigitHoles(number: int) → int

Examples

Example 1

number = 649578return = 5

Digits 6, 4, and 9 contribute one hole each, while digit 8 contributes two. The total is 5.

Example 2

number = 123return = 0

None of the digits 1, 2, or 3 contains a hole.

Example 3

number = 1000000000return = 9

The 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

IBM interview experiences

  • IBM Full-Time SWE OA Questions: 1 Experience
  • IBM Software Intern Résumé Rounds: 2 Experiences (Part 3 of 3)
  • IBM Intern Blitz Interviews: 23 Experiences (Part 2 of 3)
  • IBM Software Intern Interviews: 44 Experiences (Part 1 of 3)
  • IBM Software Intern Interview Questions: 15 Experiences
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public int countDigitHoles(int number) {
      // Write your code here.
    }

}
Checking account…