dp of length n (where n is the length of the string s) with all elements set to 1.s in reverse, starting from the second last character to the first.i, iterate over all possible lengths j such that i + 2*j <= n.j, check if s[i:i+j] is equal to s[i+j:i+2*j].dp[i] to be the maximum of dp[i] and dp[i+j] + 1.dp[0] as the result.