Count palindromic substrings
Mediumstringtwo pointersdynamic programming
Return how many contiguous parts of s read the same both ways. Parts at different positions count separately, even with the same letters.
Example 1
Input: s = "abc" Output: 3
Example 2
Input: s = "aaa" Output: 6
a, a, a, aa, aa, aaa.
Constraints
- 1 ≤ s.length ≤ 1000
- Lowercase letters
Submit checks your solution against 8 tests, including hidden ones.
/**
* @param {string} s
* @return {int}
*/
function countSubstrings(s) {
}