Count palindromic substrings at least minLength characters long
A word-puzzle game rates each row of letters by how many palindromic spans it hides. Single letters are trivially palindromes, so harder levels only count spans of at least a minimum length. Implement countPalindromes(text, minLength), which counts the palindromic substrings of text that are at least minLength characters long.
countPalindromes(text, minLength = 1) // => number
text.slice(i, j). It is a palindrome if it reads the same forwards and backwards.'aa', the two single 'a' spans and 'aa' give 3.minLength. minLength is a positive integer and defaults to 1 (count everything). If it is longer than text, the answer is 0.'A' and 'a' differ, and spaces and punctuation are ordinary characters. Treat the string as UTF-16 code units (plain text[i] indexing).text can be up to 600 characters long. Checking every substring one by one is cubic and will time out.countPalindromes('level'); // => 7 (l, e, v, e, l, eve, level)
countPalindromes('level', 3); // => 2 (eve, level)
countPalindromes('aaa'); // => 6 (a, a, a, aa, aa, aaa)
countPalindromes('noon', 2); // => 2 (oo, noon)
countPalindromes('GATTAG', 2); // => 3 (TT, ATTA, GATTAG)
countPalindromes('Aa'); // => 2 (case-sensitive)
countPalindromes('abc', 4); // => 0
countPalindromes(''); // => 0