Check Whether a Digit String Splits Into an Additive Sequence
Last updated: November 29, 2026
Quick Overview
Decide whether a digit string can be split into at least three numbers where each number after the first two equals the sum of the previous two. Numbers may not have leading zeros.
0
0
0 solved
Decide whether a digit string can be split into at least three numbers where each number after the first two equals the sum of the previous two. Numbers may not have leading zeros.
A Google technical screen that looks like general backtracking but collapses once you notice the first two numbers determine everything. The interviewer checks that insight, leading-zero handling, and big-number safety.
What the Interviewer Expects
- Notices the first two numbers fix the rest of the sequence
- Enumerates only the first two split points, then verifies greedily
- Rejects multi-digit numbers with leading zeros
- Limits the first two lengths so the third can still exist
- Mentions arbitrary-precision or string addition for very long inputs
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Return the actual split, not just True or False.
- How would you handle a string of 10,000 digits without integer conversion?
- Generalize to sequences where each term is the sum of the previous k.
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: digit string, length up to about 35.
- Output: True if it can be split into an additive sequence of length >= 3.
- Example:
"112358"is True (1, 1, 2, 3, 5, 8)."199100199"is True (1, 99...
High-Level Design
Choose the first number s[0:i] and the second s[i:j]. Once they are fixed, the third number must be their sum as a string, the fourth must be the sum of the second and third, and so on. So the onl...