Count of palindromes of length N having atmost k distinct characters such that no prefix (of size 2 to n-1) is palindrome.
If N = 3 and K = 3, possible palindromes are "aba", "aca", "bab", "bcb", "cac" and "cbc". so count is 6.
Here is a link of problem and solution
Can anyone help me with this problem. Not able to understand the solution mentioned on hackerearth as there is no editorial there. Having difficult time understanding how states are defined in solution.