how can i check a given string to form a palindrome or not
for(i=0;i<str.length();i++)
{
if(str.charAt(i)==str1.charAt(i)
}
}
pavani2006 0
Newbie Poster
Recommended Answers
Jump to PostAssuming your palindrome logic ignores case, here is one solution:
String str = "AB , ba"; StringBuffer sb = new StringBuffer(str).reverse(); String strRev = sb.toString(); if(str.equalsIgnoreCase(strRev)) System.out.println("Palindrome"); else System.out.println("Not a Palindrome");
Jump to PostYou can start off by eliminating words which don't have a repeated character. This would help you in cutting down the processing. Then with the words which have at least a pair of repeating characters, try out various combinations of the character forming the word.
For eg. if your …
Jump to Postsorry i am not trying to find the given string is palindrome or not,i am trying to find from a given string is it possible to form a palindrome or not?
suppose u input "oppa"
from this string it is possible to from a palindrome "pop"
but if u input …
Jump to Postwell... the palindrome to "opai" is "iapo".
brrrr... by my last post you can propably see I didn't sleep to well ... :)
opai is no palindrome, excuse me for the mistake
All 14 Replies
jetru 0
Light Poster
~s.o.s~ 2,560
Failure as a human Team Colleague Featured Poster
pavani2006 0
Newbie Poster
~s.o.s~ 2,560
Failure as a human Team Colleague Featured Poster
stultuske 1,116
Posting Maven Featured Poster
stultuske 1,116
Posting Maven Featured Poster
pavani2006 0
Newbie Poster
~s.o.s~ 2,560
Failure as a human Team Colleague Featured Poster
staneja 0
Junior Poster in Training
pavani2006 0
Newbie Poster
staneja 0
Junior Poster in Training
pavani2006 0
Newbie Poster
P.J.Ali 0
Newbie Poster
JamesCherrill 4,733
Most Valuable Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.