Strings In Binary

0

0 votes
Strings, Algorithms
Problem

Problem Statement:

Given a binary string S, your work is to count the number of such substrings that start and end with 1, if there is no such combination print 0.

For Example:

You are given a string 01101, the total number of substrings which starts and ends with 1 are 11, 101 and 1101.

Input Format:

The first line of the input contains an integer T, which is the number of test cases and the next line denotes the length of the string followed by the string S.

Constraints:

1 <= T <= 10

1 <= S <= 100

Output Format:

Print the count of the total number of substrings for each given string in a new line starting and ending with 1.

Example:
Input:
1
4
1111

Output:
6

Time Limit: 0.6
Memory Limit: 256
Source Limit:
Editor Image

?