Given a string str, determine the total number of substrings that are palindromes.
A palindrome is a sequence of characters that reads the same forward and backward (e.g., racecar).
A substring is any contiguous sequence of characters within a string. For example, the substrings of string abc are a, b, c, ab, bc, and abc. A substring is formed by selecting a starting and ending point without skipping characters in between.
str: string: A stringInput: str = "cat"Output: 3Explanation: The palindromic substrings are 'c', 'a', and 't'.
Input: str = "racecar"Output: 10Explanation: The palindromic substrings are 'r', 'a', 'c', 'e', 'c', 'a', 'r', 'cec', 'aceca', and 'racecar'.
Input: str = "bbb"Output: 6Explanation: The palindromic substrings are 'b', 'b', 'b', 'bb', 'bb', and 'bbb'.
str.length <= 1000str contains only lowercase English lettersconsole.log() statements will appear here.