Problem · String
Count Different Palindrome Substrings
Learn this problemProblem statement
A string S is considered palindrome if it reads same way if spelled backwards, for example "nolemonnomelon", "ASANtaLivedAsAdeviLatNASA".
Any non-empty string has substrings that are palindromes. For example, in the string S = "hellolle", there are many of such "subpalindromes":
Please write a function that, given a string S (only contains lowercase letters), returns number of different ways are there to pick a palindrome substring fro mS.
Function
countDifferentPalindromeSubstrings(s: String) → intExamples
Example 1
s = "hellolle"return = 13Output 13.
Example 2
s = "wowpurerocks"return = 14each letter + "wow" + "rer"