How to find the index of a palindrome?

How to find the index of a palindrome?

Palindrome Index. Given a string of lowercase letters in the range ascii [a-z], determine the index of a character that can be removed to make the string a palindrome. There may be more than one solution, but any will do. If the word is already a palindrome or there is no solution, return -1.

How to make a string a palindrome in HackerRank?

Hackerrank – Palindrome Index Solution. Given a string of lowercase letters in the range ascii [a-z], determine a character that can be removed to make the string a palindrome. There may be more than one solution, but any will do. For example, if your string is “bcbc”, you can either remove ‘b’ at index or ‘c’ at index .

What happens when you remove B from a palindrome?

Removing ‘b’ at index results in a palindrome, so we print on a new line. Removing ‘b’ at index results in a palindrome, so we print on a new line. This string is already a palindrome, so we print . Removing any one of the characters would result in a palindrome, but this test comes first.

How do you make a palindrome in ASCII?

The first line contains an integer , the number of queries. Each of the next lines contains a query string . All characters are in the range ascii [a-z]. Print an integer denoting the zero-indexed position of the character to remove to make a palindrome. If is already a palindrome or no such character exists, print .

How can I make a string a palindrome?

Given a string of lowercase letters in the range ascii [a-z], determine the index of a character that can be removed to make the string a palindrome. There may be more than one solution, but any will do. If the word is already a palindrome or there is no solution, return -1. Otherwise, return the index of a character to remove.

What to do if there is no palindrome in HackerRank?

If is already a palindrome or no such character exists, then print . There will always be a valid solution, and any correct answer is acceptable. For example, if “bcbc”, we can either remove ‘b’ at index or ‘c’ at index . The first line contains an integer, , denoting the number of test cases.

What happens if you remove B from index?

Removing ‘b’ at index results in a palindrome, so return . Removing ‘b’ at index results in a palindrome, so return . This string is already a palindrome, so return . Removing any one of the characters would result in a palindrome, but this test comes first. Note: The custom checker logic for this challenge is available here.