Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Least Palindromes

If I put in Raceca, it displays:

Enter a string ===>> Raceca
String:Raceca
Palindrome: false
Almost Palindrome: false
Least Palindrome:RacecacecaR

It's supposed to go :
Enter a string ===>> Raceca
String:Raceca
Palindrome: false
Almost Palindrome: false
Least Palindrome:RacecaR

I need to use the least amount of letters
private String leastPal()
{
String temp="";
if(isPal(s1)==true)
{
return s1;
}
else
{
String e="";
String f="";
int j=s1.length();
for(int k=0; k<j; k++)
e=s1.substring(0,k);
int h=e.length();
for(int m=h-1;m>=0; m--)
{
f+=s1.charAt(m);
temp=s1+f;
if(isPal(temp))
{


return temp;

}

}}
return temp;

}


How could I change it so that it stops at the first letter, checks, and then goes throught the loop again? Thanks for your help :)
[1047 byte] By [docfish] at [2007-11-11 7:49:54]
# 1 Re: Least Palindromes
Hi

I am Beena.I am looking for a project topic for my mca main project.I pefer to do it in c# ( any web related project).

Actually it is a group project(three members including me).So the project should be big enough to divide it as three modules.Plz tell the project topic and a brief summary of that project,b'coz we want to discuss it with our guide in technopark,then only they will give permission to do the project.Plz mail me the topic and its's summary.

Plz help me it's very urgent.Hope for a good result.

By
Beena
beena at 2007-11-11 22:37:09 >