top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Can you Find number of operations to form a Palindrome?

+4 votes

To do this, you have to follows two rules:

  1. You can reduce the value of a letter, e.g. you can change d to c, but you cannot change c to d.
  2. In order to form a palindrome, if you have to repeatedly reduce the value of a letter, you can do it until the letter becomes a. Once a letter has been changed to a, it can no longer be changed.

for example: for string abc
total 2 number of operations needed to make it a palindrome.

posted Mar 24, 2016 by Shahsikant Dwivedi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

/*assuming c->b is one operation and b->a as second operation and assuming ahaeder files stdio.h ,string.h and stdlib.h (for abs() function)

int main()
    char str[80];
    int count=0,i,l,j;
return 0;
answer Mar 28, 2016 by Aman Mehrotra
Similar Questions
+8 votes

Convert the given string into palindrome with minimum number of appends(at end of the given string). O(n) algorithm will be appreciated ??

Input :=> Malayal
Output :=> Malayalam

+1 vote

Given a string and dictionary of words, form a word by removing minimum number of characters.
Characters can be removed in-order only.

0 votes

Given a string, add some characters to the from of it so that it becomes a palindrome.
1) If input is "abc" then "bcabc" should be returned.
2) input -> "ab" output -> "bab"
3) input -> "a" output -> "a"

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.