题目描述
Given string s, the task is to find the count of all substrings which have the same character at the beginning and end.
Example 1:
Input: s = "abcab"
Output: 7
Explanation: a, abca, b, bcab,
c, a and b
Example 2:
Input: s = "aba"
Output: 4
Explanation: a, b, a and aba
User Task:
Your task is to complete the function countSubstringWithEqualEnds() which takes a single string as input and returns the count. You do not need to take any input or print anything.
Expected Time Complexity: O(|str|)
Expected Auxiliary Space: O(constant)
Constraints:
1 <= |s| <= 10^{4}
s contains lower case english alphabets
输入格式
见题面
输出格式
见题面
样例输入
s = "abcab"
样例输出
7