Additive Number
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A digit string is **additive** if it can be cut into a sequence of at least three numbers where every number after the first two equals the sum of the two numbers before it.
No number in the sequence may have a leading zero, although the single digit "0" is allowed. All digits of num must be used, in order.
Return true if num is additive, otherwise false. Numbers can exceed 64-bit range, so reason about them carefully in languages without big integers.
Examples
Constraints
- `1 <= num.length <= 35`
- `num` consists only of digits
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.