Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems. ×

Count of palindromes of length N having atmost k distinct characters such that no prefix (of size 2 to n-1) is palindrome

Revision en2, by lsr10122018, 2019-09-24 16:37:44

Count of palindromes of length N having atmost k distinct characters such that no prefix (of size 2 to n-1) is palindrome.

for example 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 https://www.hackerearth.com/problem/algorithm/avoid-prefix-palindromes-cdd47bd7-780d0bca/editorial/

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.

Tags #dynamic programing, #palindrome, #arrays, #algorithms

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English lsr10122018 2019-09-24 16:37:44 10
en1 English lsr10122018 2019-09-24 11:51:18 721 Initial revision (published)