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 Post> i am not trying to find i am trying to form a palindrome fron the letters of the given string
Use the approach suggested by me in my previous post.
Jump to Posthey i think what you can do is you find the frequency of characters in a word
Like ""madam" is having 2 m and 2 "a" and 1"d" so u can make pallindronme for itIts just a logic that u can think abt...Hope it will help u in …
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.