Given a string, the task is to find whether it contains an additive sequence or not. A string contains an additive sequence if its digits can make a sequence of numbers in which every number is addition of previous two numbers. You are required to complete the function which returns true if the string is a valid sequence else returns false.
The first line of input contains an integer T denoting the no of test cases . Then T test cases follow . Each test case contains a string s .
For each test case in a new line output will be 1 if it contains an additive sequence and 0 if it doesn't contains an additive sequence.
1<=length of string<=200
1. In first test case series will be (1 2 3 5 8 13 ) as 1+2=3, 2 + 3 = 5, 3 + 5 = 8, 5 + 8 = 13 .
2. In the second test case there is no such series possible.
3. In the third test case there is the series will be 1 99 100 199 .
Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.