HackerEarth Interview Question for Problem Setters
- 0of 2 votes
A special palindrome is a palindrome of size N which contains atmost K distinct characters such that any prefix between the size 2 to N-1 is not a palindrome.- Prashanthwagle360 September 08, 2019 in India
You need to count the number of special palindromes
For example, abba is a special palindrome with N=4 and K=2 and ababa is not a special palindrome because aba is a palindrome and its a prefix of ababa.
If N=3, K=3, possible special palindromes are aba, aca, bab, bcb, cac and cbc. So answer will be 6.
Two integers N and K
Answer modulo 10^9+9
| Report Duplicate | Flag | PURGE
HackerEarth Problem Setter Algorithm
Interview Type: Written Test
Open Chat in New Window