Computer Science, asked by meghanahulagur6, 4 months ago

Alice has a string s of lowercase latin letters. Bob saw Alice enjoying her string, and he immediately thought about the following question: is there a way to replace exactly one letter in S, such that there's permutation of the resultant string which is palindrome
sample input -3,qa, S, rlix
sample output -2

Answers

Answered by anvisha27008
0

Answer:Problem

Alice and Bob are playing a game with a string of English alphabets (both uppercase and lowercase). They can select a character either from the start or end of the string. Put the selected character in a common box. The winner of the game is the first person who can make a string palindrome of length greater than 1 by using some of the box's characters. Alice starts first to pick a character and both players play optimally. Determine the winner of the game or depict if it is a Tie.

Note: A tie occurs when no one wins.

For example: If the string is aabc, then Alice can select the character 'a' or 'c' and store it into the box. If Alice chooses 'a', then the resulting string for Bob is abc. This helps Bob so that he can select either 'a' or 'c', so he can select 'a' and store it into box. Now, Bob can make a string 'aa' which is a palindrome of length is greater than 1. Hence, Bob wins the game.

Input format

Explanation:

Similar questions