← ALL NOTES
Array

2213. Longest Substring of One Repeating Character

Each query flips one character of the string and then asks for the longest block of a single repeated character in the whole string, so the real move is to make "longest run" a mergeable quantity and hang it on a segment tree. The naive instinct — rescan the string after every edit — is O(n*k), and with n and k both up to 10^5 that is 10^10 character comparisons; it times out.

Loading…