Find the substrings
Practice
3.3 (23 votes)
Algorithms
Medium
Problem
35% Success 5290 Attempts 30 Points 3s Time Limit 256MB Memory 1024 KB Max Code
Given a string S made of letters a, b and c, find the number of sub strings that do not contain all the letters a, b and c. That is the number of sub strings that do not contain at least one of the letters a or b or c.
Note that the sub string should contain atleast one letter, that is it should not be empty string.
Input
First line of the input is the number of test cases T. It is followed by T lines. Each test case is a single line which is the string S.
Output
For each test case, print a single number, the required answer.
Constraints
1 <= |S| <= 10^6
Submissions
Please login to view your submissions
Similar Problems
Points:30
9 votes
Tags:
Ad-HocAlgorithmsApprovedMediumOpen
Points:30
57 votes
Tags:
ReadyMathematicsOpenApprovedEasy-MediumMathamatics
Points:30
24 votes
Tags:
AlgorithmsApprovedData StructuresMediumOpenSorting
Editorial