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

If we have no srs, brs but we have test cases does you execute the test cases blindly or do you follow any other process?

994


Hi Friends, I have completed 3 rounds of an Interview with HR discussion also and got Offer letter from Cognizant, but after in 30 min they send one more email like Offer is on Hold, and its not valid... Could you please guide me any one , Can i expect Offer again from Cognizant or Can i drop the hopes ?.

1597


Write a set of test cases to test youtube?

7402


What is an audit report? Whom is it done by?

2161


few automation basic questions One question to write a scriot in any language you know.

1978


What are the typical risks that you identify during test planning and their mitigation plan and Contengency plan.

2278


What is Test Design ?( Urgent) and Test Design for Printer?

1792


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

2965


write test condition for testing SMS service of a mobile phone maximun length is 100 character while sending and 80 character for receiving write test scenarios do not write test cases

3279


What is alpha testing?

864


how will we change the server system time?

1986


What is the purpose of test strategy?

877


What are the principles of software testing?

851


What are the different servers and difference between them?

1867


Describe any bug you remember. Plz Give some real examples

1859