Write an algorithm to find an palindrome

Answer Posted / sagai

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
}
firstCnt++
secCnt--
}
return true //if loop completes without a false, is a
palinrome
}

Is This Answer Correct ?    20 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is your daily activities?

1655


what are risks and contigencies(solutions) of an ecommerce (online shopping and bidding project)application?we describe this in Test plan can anyone tell me abt this?

1563


How should your staff be managed? How about your overtime?

2753


What is sanity?

622


a newly launched web site is hosted on web server.It is expected that 100 people visit the website every hour and browse 30 pages spending a total 15 minutes. what is the maximum hits/sec that the web server should support this load?justify your answer. need urgently. by rimesh

1408






What is an error?

659


Can you please provide me the standard testcase review templete and Test plan templete.In my company we are not following any Standards templete so.Please guve me some Excell attachments.

2130


You may be overqualified for this position we have to offer

1724


Need to know about Quality Center in brief

1465


Do we have any certifications for ETL Testing ?

1725


What is the procedure of manual testing?

633


what is the difference between test case and result matrix

1675


which sanity testing is performed?

1173


what is functional testing terminologies

1906


Work flow in testing in your company?

1339