647. Palindromic Substrings 回文子串
❀ Origin
Problem
Given a string, your task is to count how many palindromic substrings in this string.
The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.
Note
- The input string length won’t exceed 1000.
Example 1
1 | Input: "abc" |
Example 2
1 | Input: "aaa" |
❀ 翻譯
問題
給定一個字串, 你的任務是算出這個字串裡有幾個回文子串.
具有不同起始位置和結束位置的子字串符會被計算成不同的子字串, 即使他們包含著相同的字元.
注意
- 輸入字串的長度不會超過 1000.
❀ Solution
JavaScript
1 | /** |
JavaScript II
1 | /** |
JavaScript III
1 | /** |
Golang
1 | func countSubstrings(s string) int { |