Count even substrings
Submissions: 1624   Accuracy:

53.2%

  Difficulty: Basic   Marks: 1

Given a string of digits 0 – 9. The task is to count number of substrings which when convert into integer form an even number.

Examples:

Input : s = "1234".
Output : 6
"2", "4", "12", "34", "234", "1234" 
are 6 substring which are even.

Input : s = "154".
Output : 3

Input : s = "15".
Output : 0

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 the count of even sub-strings .

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

Example:
Input:

2
1234
154
Output:
6
3

** 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.