882. Count Palindromic Substrings by Expanding Centers
Medium•
Let n = text.length.
functioncountPalindromes(text){let count =0for(let center =0; center <2* text.length-1; center++){let left =Math.floor(center /2)let right = left +(center %2)while(left >=0&& right < text.length&& text[left]=== text[right]){ count++ left-- right++}}return count
}
What are the worst-case time and auxiliary space complexities?