Distinct Substrings
Submissions: 1298   Accuracy:

45.43%

  Difficulty: Easy   Marks: 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".

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

Author: dipjal1996


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.