Zoho Logo

Asked in Zoho

Make Palindrome Problem Statement

You are provided with a string STR of length N comprising lowercase English alphabet letters. Your task is to determine and return the minimum number of characters that need to be added at the beginning of the string to make it a palindrome.

Input:

The first line contains an integer 'T' indicating the number of test cases. Each test case is given in a single line containing the string STR.

Output:

For each test case, output the minimum number of characters required to make the string a palindrome, each on a new line.

Example:

Input:
T = 2
STR = "deed"
STR = "aabaaca"
Output:
0
2

Constraints:

  • 1 <= T <= 100
  • 1 <= N <= 5000
  • STR contains only lowercase English letters.
  • Time limit: 1 second

Note:

Implementation should focus on determining the function to calculate the required number without outputting results directly.
AnswerBot
4mo

The task is to determine the minimum number of characters needed at the beginning of a string to make it a palindrome.

  • Iterate from both ends of the string and compare characters to find the number of ...read more

Help your peers!
Select
Add answer anonymously...

Top SDE-2 Interview Questions Asked at Zoho

Q. You are given a rectangular container filled with 1 liter of liquid. How can you...read more
Q. Wildcard Pattern Matching Problem Statement Implement a wildcard pattern matchin...read more
Q. What is BCNF and why is it important in database management systems?
SDE-2 Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits