Substrings
Practice
3.6 (17 votes)
Algorithms
Basic programming
Easy
String manipulation
Problem
84% Success 8036 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You have a string S, but you like only special strings. So, you have to calculate the total number of special substrings in S.

A string T, of length L, is called special string, if either of the following property holds:

  1. All characters of the string T are same. for example, \(aaa\)
  2. The string has an odd length (i.e, L is odd) and all characters of T are same except the middle character, for example, \(aabaa\).

Count the total number of special substrings in S.

Input constraints:

  • String S contains only lower-case English alphabets.
  • \(1 \le|S| \le10^{6}\), where |S| is the length of string S.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
36 votes
Tags:
Ad-HocApprovedData StructuresEasyImplementationOpen
Points:20
45 votes
Tags:
Ad-HocApprovedEasyOpen
Points:20
1 votes
Tags:
AlgorithmsBasics of String ManipulationString Algorithms