Error
|
|
---|---|
@Ibrahim Nash | 5765 |
@blackshadows | 5715 |
@akhayrutdinov | 5111 |
@mb1973 | 4993 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 1280 |
@bt8816103042 | 739 |
@rohitanand | 495 |
@codeantik | 479 |
@shalinibhataniya1097 | 472 |
@amrutakashikar2 | 464 |
@thealchemist627 | 456 |
@akashkale117 | 453 |
@shivanandp12345678910 | 453 |
@dalwainazism125 | 453 |
@SherlockHolmes3 | 447 |
Complete Leaderboard |
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| <= 104
s contains lower case english alphabets
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes