给定一个字符串,返回这个字符串中有多少个回文子串。 两个相同的回文子串出现在不同的位置,认为是2个回文子串。 a、aa、aaa、aba、aabaa、abcba均认为是回文子串。
示例1
输入
"aaa"
输出
6
说明
a、a、a、aa、aa、aaa
示例2
输入
"abcb"
输出
5
说明
a、b、c、b、bcb
加载中...
import java.util.*; public class Solution { /** * * @param str string字符串 * @return int整型 */ public int palindromeCount (String str) { // write code here } }
class Solution { public: /** * * @param str string字符串 * @return int整型 */ int palindromeCount(string str) { // write code here } };
# # # @param str string字符串 # @return int整型 # class Solution: def palindromeCount(self , str ): # write code here
/** * * @param str string字符串 * @return int整型 */ function palindromeCount( str ) { // write code here } module.exports = { palindromeCount : palindromeCount };
# # # @param str string字符串 # @return int整型 # class Solution: def palindromeCount(self , str ): # write code here
package main /** * * @param str string字符串 * @return int整型 */ func palindromeCount( str string ) int { // write code here }
/** * * @param str string字符串 * @return int整型 */ int palindromeCount(char* str ) { // write code here }
"aaa"
6
"abcb"
5