FastPrepDigit Changes for a Multiple of 9
Problems/Digit Changes for a Multiple of 9

Digit Changes for a Multiple of 9

Nutanix logoNutanix● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A 2025 campus internship report listed this as one of three questions in the Nutanix online assessment. You get a string of digits. You may turn 2s into 4s and 3s into 9s. You answer whether the number can become a multiple of 9.

The report does not say how many digits may change, whether a number that is already a multiple of 9 counts, or how long the string can be. Here you may change any of the 2s and 3s or none of them. A number that is already a multiple of 9 counts as true. The string has up to 10^5 digits, and leading zeros are allowed.

Our version is about 90% the same as the reported question.

You are given a string num made only of decimal digits. It stands for a whole number, and leading zeros do not change its value.

You may change some digits of num, but only in these two ways:

  • a digit 2 may become a 4;
  • a digit 3 may become a 9.

You can pick any set of the 2s and 3s to change, including none of them. No other digit can change.

Return true if some choice of changes makes the number a multiple of 9, and false otherwise.

Function

canMakeMultipleOfNine(num: String) → boolean

Examples

Example 1

num = "322"return = true

The digits add up to 3 + 2 + 2 = 7, so 322 is not a multiple of 9. Change one of the two 2s into a 4 to get 342. Its digits add up to 9, and 342 = 9 * 38. You do not have to change every 2.

Example 2

num = "1234"return = true

The digits add up to 10. Changing only the 2 gives a digit sum of 12, and changing only the 3 gives 16. Changing both gives 1494, whose digits add up to 18, and 1494 = 9 * 166.

Example 3

num = "23"return = false

The four possible numbers are 23, 43, 29 and 49. Their digit sums are 5, 7, 11 and 13, and none of them is a multiple of 9.

Constraints

  • 1 <= num.length <= 10^5
  • num contains only the digits 0 to 9.

More Nutanix Online Assessment questions

  • Good SubsequencesOA · Seen Jul 2026
  • Min Cost to Connect All PointsOA · Seen Jun 2026
  • Gas Station Loop StartOA · Seen Aug 2025
  • Number of Players (for MTS2)OA · Seen Oct 2024
  • Work Schedules (for MTS2)OA · Seen Oct 2024
  • Minimum Operations to Convert ArrayOA · Seen Apr 2024
  • No Adjacent CharactersOA · Seen Apr 2024
  • Build a BST From a ListOA · Seen Nov 2022
  • Delete Even-Valued Nodes From a Linked ListOA · Seen Nov 2022
  • Maximum Value of the Last RobotOA · Seen Aug 2021

Similar questions at other companies

  • Binary CircuitAkuna Capital · OAAkuna Capital interview questions
  • Return Exact Cash Register ChangeBank of America · OA
  • Minimize Expression with ParenthesesPinterest · OAPinterest interview questions
  • Minimum Digit Swaps for the Smallest DifferenceLSEG · OALSEG interview questions
  • Minimize Difference Between Two NumbersMicrosoft · OAMicrosoft interview questions
  • Maximum Binary Circuit Segregation CostAdobe · OAAdobe interview questions
  • Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions
  • Smallest Number With a Given Digit SumAmazon · ONSITE INTERVIEW
  • Maximum Ones After K OperationsGoldman Sachs · OAGoldman Sachs interview questions
  • Server InvestmentRippling · OARippling interview questions

Interview reports that mention this question

  • Nutanix Intern Debugging Round and Interviews: 25 Experiences

Nutanix interview experiences

  • Nutanix SWE Intern Phone Screens: 20 Experiences (Part 3 of 3)
  • Nutanix SWE Intern OA Questions: 16 Experiences (Part 2 of 3)
  • Nutanix U.S. SWE Intern Interviews: 54 Experiences (Part 1 of 3)
  • Nutanix SWE OA and Interviews, Level Not Reported: 9 Experiences
All Nutanix interview questionsSee Nutanix hiring insights
Saved
class Solution {
    public boolean canMakeMultipleOfNine(String num) {
        // Write your code here.
    }
}
Checking account…