- 1of 3 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 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
bettylfoster, University dean at Littler's
Hi , I am Betty from the USA , working as Dien in Littler's University for the last three years. Previously ...
TaylahMacge, Consultant at Accenture
Assigned to manage the requirements of foreign clients specifically those from the Chinese, Arabic, and French-speaking markets.I am passionate ...
markhlee8, Research Scientist at Bank of America
I am a cooking Instructor in New York USA, I Have a degree from the prestigious Culinary Arts Institute of ...
Hello friends my name Neha Nanda from India Chandigarh city. Doing work in SEO line in Softsys company.
marktrejjo, Data Engineer at Accolite software
I’m Mark.I believe life is too short to be serious all the time, so if you cannot laugh ...
TinaaJohn, Cloud Support Associate at AMD
Hi,Everyone.I am an art teacher at Woodson Institute.Foster and encourage critical thinking and analysis about art and ...
juanajcox4, Python Developer at Axiom Sources
I have 2 years of experience in designing and implementing computer algorithms or models for creating, displaying, and processing various ...
JenniferSRoe, Android test engineer at Accolite software
I am Jennifer from Dublin. I am Photographer, I have experienced in all different kinds of photography -Strong aesthetic sense ...
kevinlmoses, Animator at Accenture
I am Experienced Building Manager who is an expert in public and industrial safety with a preventative mindset against fire ...
I am an energetic sales professional with a track record of consistently increasing sales revenue in a competitive market. Contract ...