Tap here to switch tabs
Problem
Ask
Submissions

Problem: Additive Number

med
30 min
Explore how to determine if a digit string forms an additive sequence by applying backtracking algorithms. Understand the constraints on valid sequences and practice implementing solutions to develop deeper problem-solving skills in coding interviews.

Statement

An additive number is a string whose digits can be partitioned into an additive sequence.

A valid additive sequence contains at least three numbers, where every number after the first two is equal to the sum of the two immediately preceding numbers.

Given a string, num, containing only digits, determine whether it represents an additive number. Return TRUE if a valid additive sequence can be formed from the digits of num, and FALSE otherwise.

Note: Numbers in the additive sequence cannot have leading zeros. For example, the sequences 1, 2, 03 and 1, 02, 3 are both invalid.

Constraints:

  • 11 \leq num.length 35\leq 35

  • num consists only of digits.

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Additive Number

med
30 min
Explore how to determine if a digit string forms an additive sequence by applying backtracking algorithms. Understand the constraints on valid sequences and practice implementing solutions to develop deeper problem-solving skills in coding interviews.

Statement

An additive number is a string whose digits can be partitioned into an additive sequence.

A valid additive sequence contains at least three numbers, where every number after the first two is equal to the sum of the two immediately preceding numbers.

Given a string, num, containing only digits, determine whether it represents an additive number. Return TRUE if a valid additive sequence can be formed from the digits of num, and FALSE otherwise.

Note: Numbers in the additive sequence cannot have leading zeros. For example, the sequences 1, 2, 03 and 1, 02, 3 are both invalid.

Constraints:

  • 11 \leq num.length 35\leq 35

  • num consists only of digits.