is there any patterns i can use to sort out how to create a string that is palindrome which made up with 'X' 'Y'
Let's assume n is even. Generate every string of length n/2 that consists of x and y, and append its mirror image to get a palindrome.
Exercise 1: prove that this generates all palindromes of length n.
Exercise 2: figure out what to do when n is odd.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With