FastPrepLargest Number with a Given Digit Sum
Problems/Largest Number with a Given Digit Sum

Largest Number with a Given Digit Sum

Intuit logoIntuit● EasyFULLTIMEOA

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The source names largest number by digit sum and digit count. Leading-zero, impossible-case, and return-size rules are practice assumptions; about 95% match.

Return the largest nonnegative decimal integer with exactly digits digits and digit sum sum, as a string. Leading zeros are forbidden except for the one-digit number zero. If no such number exists, return "-1".

Function

largestNumber(digits: int, sum: int) → String

Examples

Example 1

digits = 3sum = 20return = "992"

Put the largest feasible digits in the most significant positions.

Example 2

digits = 2sum = 0return = "-1"

A two-digit number cannot have digit sum zero.

Constraints

  • For this exercise, assume 1 <= digits <= 100000 and 0 <= sum <= 900000.

More Intuit Online Assessment questions

  • Employee Promotion OpportunitiesOA · Seen Oct 2026
  • Next Pascal Row CoefficientOA · Seen Oct 2026
  • Parse Router LogsOA · Seen Oct 2026
  • Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
  • Maximum Square-Free DivisorOA · Seen Oct 2026
  • Two Tribes from Taller-Person CountsOA · Seen Oct 2026
  • Shortest Path from an Encoded GraphOA · Seen Sep 2026
  • Oldest and Youngest EmployeesOA · Seen Sep 2026
  • Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
  • Submask Sum QueriesOA · Seen Sep 2026

Similar questions at other companies

  • Maximum Ones After K OperationsGoldman Sachs · OAGoldman Sachs interview questions
  • Minimum Operations to Reduce a Transaction LedgerVisa · OAVisa interview questions
  • Prepare NotificationMicrosoft · OAMicrosoft interview questions
  • Minimum Changes for Distinct Adjacent CharactersHeadlands Technologies · OAHeadlands Technologies interview questions
  • Largest Number With Even Digit FrequenciesDRW · OADRW interview questions
  • Minimum Replacements for Unequal Adjacent CharactersIBM · OAIBM interview questions
  • Crop Text at a Whole-Word BoundaryAmerican Express · OAAmerican Express interview questions
  • Minimum Flips for Even Binary RunsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Missing WordsVanguard · OAVanguard interview questions
  • Digit Changes for a Multiple of 9Nutanix · OANutanix interview questions

Interview reports that mention this question

  • Intuit OA: What It Tests (2026)

Intuit interview experiences

  • Intuit Software Engineering Intern - Full Stack OA Format
All Intuit interview questionsSee Intuit hiring insights
Saved
class Solution {
    public String largestNumber(int digits, int sum) {
        // Write your code here
    }
}
Checking account…