Palindromic Substrings
Count all palindromic contiguous substrings, counting different index ranges separately even when their text is equal.
Example 1
s = "aaa"6Explanation
Three single letters, two aa ranges and one aaa range total six.
Example 2
s = "abc"3Explanation
Only the three single-character ranges are palindromes.
Example 3
s = "abba"6Explanation
Four single letters, bb and abba total six.
Constraints
- 1 <= len(s) <= 1000
- s contains lowercase English letters
Function contract
countSubstringsArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 34 cases, on your device.
"aaa"