String with numbers at its end
Submissions: 6487   Accuracy:

31.81%

  Difficulty: Basic   Marks: 1

Given a string (S) that is appended with a number at last. You need to find whether the length of string excluding that number is equal to that number. For example for “helloworld10”, answer is True as helloworld consist of 10 letters. 

Examples:

Input:  S = "geeks5"
Output:  1
Explanation : As geeks is of 5 length and at 
              last number is also 5.

Input:  S = "geeksforgeeks15"
Output:  0
Explanation: As geeksforgeeks is of 13 length and
             at last number is 15 i.e. not equal


Input:
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.

Output:
For each test case in a new line print 1 if the condition holds else print 0.

Constraints:
1<=T<=100
1<=Length of string<=1000

Example:
Input:

2
geeks5
geeksforgeeks15
Output:
1
0

** For More Input/Output Examples Use 'Expected Output' option **

Author: Shubham Joshi 1


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.