#C9644. Can Form Palindrome?
Can Form Palindrome?
Can Form Palindrome?
Given a string S consisting of lowercase alphabets and asterisks (*
), determine whether it is possible to replace all asterisks with appropriate characters so that the resulting string is a palindrome.
A palindrome is a string that reads the same forwards and backwards. Formally, let the length of S be n. After replacing each *
as needed, the string is a palindrome if and only if for all indices \(0 \leq i < n\), the character at position i equals the character at position \(n-1-i\) (i.e., \(S[i] = S[n-1-i]\)).
For example, when S = "a*b*a", one can replace the asterisk with 'b' to form "ababa", which is a palindrome, so the answer is "Yes". If it is impossible to form a palindrome with any replacement, return "No".
inputFormat
The input is provided via standard input (stdin) as a single line containing the string S. The string consists of lowercase alphabets and the character *
.
outputFormat
Output a single line via standard output (stdout) containing either "Yes" or "No". "Yes" indicates that it is possible to replace the asterisks to form a palindrome; otherwise, output "No".
## samplea*b*a
Yes