FastPrepSmallest Larger Integer with Twice the Digit Sum
Problems/Smallest Larger Integer with Twice the Digit Sum

Smallest Larger Integer with Twice the Digit Sum

Marshall Wace logoMarshall Wace● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Marshall Wace phone screen. The author wrote this from memory. It leaves out the input limits and does not say outright that the result must be larger than the input. Its example of 10 giving 11 supports that reading. We added limits. Our version is about 85% the same as the reported question.

For a positive integer N, let its digit sum be the sum of its decimal digits.

Return the smallest integer M such that:

  • M > N, and
  • the digit sum of M is exactly twice the digit sum of N.

For this exercise, assume the answer must be strictly greater than the input. For example, 10 -> 11.

Function

solution(N: int) → long

Examples

Example 1

N = 14return = 19

The input digit sum is 5. The result has digit sum 10 and is the smallest qualifying integer greater than 14.

Example 2

N = 10return = 11

The input digit sum is 1. The result has digit sum 2 and is the smallest qualifying integer greater than 10.

Example 3

N = 99return = 9999

The input digit sum is 18. The result has digit sum 36 and is the smallest qualifying integer greater than 99.

Constraints

  • For this exercise, assume 1 <= N <= 10^9.
  • Return an exact signed 64-bit integer. The answer exists and is at most 999999999999999999 under this input bound.

More Marshall Wace interview questions

  • Maximum Sum with at Most Three Two-Element TilesPHONE SCREEN · Seen Sep 2025
  • Minimum Full Glasses for an Exact Water VolumePHONE SCREEN · Seen Sep 2025
  • Smallest Absolute Difference Between Two Array ElementsPHONE SCREEN · Seen Sep 2025
  • Maximum Frog Separation with One Upward Jump (Practice Reconstruction)PHONE SCREEN · Seen Jul 2023
  • Minimum Deletions Before Rearranging into a PalindromePHONE SCREEN · Seen Jul 2023
  • Count Squares of Any OrientationPHONE SCREEN · Seen Oct 2019
  • Count Letters with Ordered Lowercase and Uppercase OccurrencesOA · Seen Oct 2025
  • Maximum Trailing Zeros on a Path with at Most One TurnOA · Seen Oct 2025
  • Shortest Subarray Covering an Integer RangeOA · Seen Oct 2025
  • Maximum Events in a 60-Second WindowOA · Seen Aug 2025

Similar questions at other companies

  • Apartment Housemate PreferencesGoogle · PHONE SCREENGoogle interview questions
  • Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions
  • Minimum Operations to Make Every Array Element OneOtter.ai · PHONE SCREENOtter.ai interview questions
  • Evenly Schedule Vehicle InspectionsAmazon · PHONE SCREEN
  • Fair Electoral Vote ApportionmentBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • IP Address to CIDR BlocksOpenAI · PHONE SCREENOpenAI interview questions
  • Best Starting Cell for Restaurant DistanceDoorDash · PHONE SCREENDoorDash interview questions
  • Minimum Fuel Car AlignmentFivetran · PHONE SCREENFivetran interview questions
  • Most Ones in a Matrix With a Zero PowerSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Town Temperature Regression AnalysisCitadel · PHONE SCREENCitadel interview questions

Interview reports that mention this question

  • Marshall Wace Coding Tests: 11 Experiences (Part 2 of 3)
  • Marshall Wace Quant and Coding OA: 19 Experiences (Part 1 of 3)

Marshall Wace interview experiences

  • Marshall Wace Older Quant Tests: 5 Experiences (Part 3 of 3)
All Marshall Wace interview questionsSee Marshall Wace hiring insights
Saved
class Solution {
    public long solution(int N) {
        // Write your solution here.
    }
}
Checking account…