Smallest Larger Integer with Twice the Digit Sum
Updated
Problem statement
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
Mis exactly twice the digit sum ofN.
For this exercise, assume the answer must be strictly greater than the input. For example, 10 -> 11.
Function
solution(N: int) → longExamples
Example 1
N = 14return = 19The input digit sum is 5. The result has digit sum 10 and is the smallest qualifying integer greater than 14.
Example 2
N = 10return = 11The input digit sum is 1. The result has digit sum 2 and is the smallest qualifying integer greater than 10.
Example 3
N = 99return = 9999The 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
999999999999999999under 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