Class Solution

java.lang.Object
g0601_0700.s0647_palindromic_substrings.Solution

public class Solution extends Object
647 - Palindromic Substrings.<p>Medium</p> <p>Given a string <code>s</code>, return <em>the number of <strong>palindromic substrings</strong> in it</em>.</p> <p>A string is a <strong>palindrome</strong> when it reads the same backward as forward.</p> <p>A <strong>substring</strong> is a contiguous sequence of characters within the string.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> s = &ldquo;abc&rdquo;</p> <p><strong>Output:</strong> 3</p> <p><strong>Explanation:</strong> Three palindromic strings: &ldquo;a&rdquo;, &ldquo;b&rdquo;, &ldquo;c&rdquo;.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> s = &ldquo;aaa&rdquo;</p> <p><strong>Output:</strong> 6</p> <p><strong>Explanation:</strong> Six palindromic strings: &ldquo;a&rdquo;, &ldquo;a&rdquo;, &ldquo;a&rdquo;, &ldquo;aa&rdquo;, &ldquo;aa&rdquo;, &ldquo;aaa&rdquo;.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= s.length <= 1000</code></li> <li><code>s</code> consists of lowercase English letters.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • countSubstrings

      public int countSubstrings(String s)