Write an algorithm to find an palindrome

Answer Posted / nandan_101

boolean isPalindrome(string s){
char[] letters = s.toCharArray() //convert string to
array of characters
int firstCnt = 0 //counter for left side
int secCnt = letters.length - 1 //counter for right
side
while (firstCnt < secCnt){ //work toward middle
if (letters[firstCnt] != letters[secCnt]){
return false //if left and right does not
match, is not a palindrome
}
}
return true //if loop completes without a false, is a
palinrome
}boolean isPalindrome(string s){
char[] letters = s.toCharArray() //convert string
<strong class="highlight">to</strong> array of characters
int firstCnt = 0 //counter for left side
int secCnt = letters.length - 1 //counter for right
side
while (firstCnt < secCnt){ //work toward middle
if (letters[firstCnt] != letters[secCnt]){
return false //if left and right does not
match, is not a <strong
class="highlight">palindrome</strong>
}
}
return true //if loop completes without a false, is a
palinrome
}

Is This Answer Correct ?    5 Yes 18 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

hai friends i did my bcom (distance with out inter)and iam pursuing mca(distance alagappa university)iam learning testing cource in ameerpet can i elgibel for testing jobs pls guide me … …and send details to rangavijetha@gmail.com..thanks

1628


what is the difference between Risk based and Requirement based testing???

1948


which domain is of high demand for software testing, Right now i am working in Education domain .How about demand for Education domain and which companies are recruiting in education domain

3404


Suggest some book to learn more test case???

1678


what is date field test case

1657


send the senario template

1677


What is the Testing strategy for testing client server applications/products?

2064


what is TAS language which is used as a language for some projects/

1810


Any one please can u tell me what is composer? An interviewer asked me do u have experience in Composer? its urgent.

1819


What are the main key components in client and server applications?

887


What is client server application testing?

1726


What's the difference between system testing and acceptance testing?

918


when database testing comes into manual tesing

1938


Can you explain the elementary process?

862


Explain branch coverage and decision coverage.

872