The word game from before now scores whole paragraphs, up to 200,000 characters long, so counting from every center one step at a time is too slow.
Write countAllMirrors(text) that returns how many substrings of text read the same forward and backward. Substrings at different positions count separately, and single letters count.
Input: text = "aaa" Output: 6
Three single letters, two aa, and one aaa.
Input: text = "abc" Output: 3
Only the three single letters.
0 <= text.length <= 2 * 10^5text contains lowercase letters.Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #611 Count Mirrored Snippets at Scale. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.