返回字符串中回文子串的数目
const countSubstrings = (s) => { let len = s.length if([0,1].includes(len)) return len let res = 0 const getStr = (s, l, r) => { while(l >= 0 && r <= s.length && s[l] === s[r]){ res++ l--; r++ } } for(let i = 0; i < s.length; i++){ getStr(s, i, i) getStr(s, i, i + 1) } return res };
以自己现在的努力程度,还没有资格和别人拼天赋