647. Palindromic Substrings
Description
See: https://leetcode.com/problems/palindromic-substrings/
Solution
This problem is similar to question 5 - "Longest Palindromic Substring". It uses the same expand around the center technique as that question to solve the problem.
Here, we need to find the number of substrings that are palindromic. Instead of iterating over each substring, we can use "expand around the center". So at each character, we decrement/increment the left and right pointers and check if the values are equal or not.
Time complexity: O(N^2).
Space complexity: O(1)
Last updated