Problem title
Difficulty
Avg time to solve

Best Time to Buy and Sell Stock II
Moderate
--
Remove All The Palindromes
Moderate
--
Party Over
Easy
--
Water Supply In A Village
Hard
45 mins
NINJA’S STRING
Moderate
25 mins
Remove character
Easy
--
Longest Common Substring
Moderate
25 mins
Sort Stack
Easy
20 mins
Rat In A Maze
Easy
15 mins
Moderate
20 mins 12

# NINJA’S STRING

Difficulty: MEDIUM
Avg. time to solve
25 min
Success Rate
75%

Problem Statement

#### Example :

``````‘1123’ is a ninja string, since ‘1 + 1 = 2’ and ‘1 + 2 = 3’.
``````

#### Note :

``````Numbers in the ninja string cannot have leading zeros, so sequence 1, 2, 03 or 1, 02, 3 is invalid.
``````

#### Input Format :

``````The first line contains an integer 'T' which denotes the number of test cases or queries to be run.

The first line of each test case contains a string ‘S’, representing the string for which you have to determine if this string is a ninja string or not.
``````

#### Output Format :

``````For each test case, print a single line as ‘True’ or ‘False’  as per the given condition.

The output of each test case will be printed in a separate line.
``````

#### Note :

``````You do not need to print anything; it has already been taken care of. Just implement the given function.
``````

#### Constraints :

``````1 <= T <= 5
1 <= |S| <= 30

Where ‘T’ represents the number of test cases and ‘S’ represents the given string.

Time Limit: 1 second
``````

#### Sample Input 1 :

``````2
112358
2356
``````

#### Sample Output 1 :

``````True
False
``````

#### Explanation Of Sample Input 1 :

``````Test Case 1:
In the first line, there is the number of test cases i.e., ‘2’, and in the next line ‘112358’ is the given string so now we look for our condition
‘1 + 1 = 2’
‘1 + 2 = 3’
‘2 + 3 = 5’
‘3 + 5 = 8’
Hence we return ‘True’ as it satisfies the given condition for the ninja string.

Test Case 2:
For this test case given string is ‘2356’
‘2 + 3 = 5’
But ‘3 + 5 = 8’ but in string ‘6’ is present so we return ‘False’ as it doesn’t satisfy the given condition for the ninja string.
``````

#### Sample Input 2 :

``````1
235813
``````

#### Sample Output 2 :

``````True
``````

#### Explanation Of Sample Input 2 :

``````Test Case 1:
In the first line, there is the number of test cases i.e., ‘1’, and in the next line ‘235813’ is the given string so now we look for our condition
‘2 + 3 = 5’
‘3 + 5 = 8’
‘5 + 8 = 13’
Hence we return ‘True’ as it satisfies the given condition for the ninja string.
``````   Console