Palindrome Degree
HardRating 2200CodeforcesString Algorithms (KMP, Z, Hashing)
Approach hintTry it first, then revealHide
A palindromic prefix of length i has degree deg[i / 2] + 1, and any other prefix has degree 0. Test whether each prefix is a palindrome in O(1) by maintaining forward and backward hashes incrementally.