Given a string s
, count the number of palindromic substrings within it.
Rules:
Constraints:
Examples:
// Example 1: console.log(countSubstrings("abc")); // Output: 3 // Explanation: Three palindromes: "a", "b", "c" // Example 2: console.log(countSubstrings("aaa")); // Output: 6 // Explanation: Six palindromes: // - Single chars: "a", "a", "a" // - Two chars: "aa", "aa" // - Three chars: "aaa"