Distinct Substrings
Easy Accuracy: 49.37% Submissions: 2423 Points: 2

Given a string S consisting of uppercase alphabetic characters. Return the  number of different substrings of size 2 that appear in S as contiguous substrings.

Input:
The first line contains 'T' denoting the number of testcases. Then follows description of test cases. The next T lines contains the string S.

Output:
Output the number of different substrings of size 2 in S.


Constraints:
1<=T<=50
1<=|S|<=100


Example:
Input :
2
ABCAB
XYZ

Output :
3
2

Explanation:  For "ABCAB", the three distinct substrings of size 2 are "AB", "BC" and "CA".  For "XYZ", the two distinct substrings of size 2 are "XY" and "YZ".

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Output Window