Company: Mathworks_31july
Difficulty: medium
Sub-Palindrome Problem Description A palindrome is a string that reads the same forwards and backwards, such as "121" or "tacocat". A substring is a contiguous sequence of characters within a string. Given a string s , count how many distinct substrings of s are palindromes. Two occurrences of the same substring text count as one. Complete the function palindrome , which accepts the string s and returns an integer. Input Format A single line containing the string s . Output Format Print a single integer: the number of distinct palindromic substrings of s . (inferred - the source describes a function that returns an integer; printing that integer on its own line is this judge's stdout contract.) Constraints 1 <= |s| <= 5000 Each character s[i] is a lowercase English letter in the range ascii[a-z] Examples Example 1 Input: aabaa Output: 5 Explanation: the distinct palindromic substrings are "a", "b", "aa", "aba", "aabaa". The substring "a" occurs four times and "aa" occurs twice, b