Write an algorithm to find an palindrome

Answers were Sorted based on User's Feedback



Write an algorithm to find an palindrome..

Answer / 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

Write an algorithm to find an palindrome..

Answer / 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

More Manual Testing Interview Questions

What is the Myers Boundary Table?

0 Answers  


What is a traceability matrix, and what is the purpose of it?

11 Answers   Apex, Matrix,


What all are the reuirements needed for UAT?

2 Answers  


How do we find pass and fail percentage of Test cases. Anybody can give answer to me. Thanks in advance

2 Answers   HCL, Satyam,


Why we have to do manual testing?

0 Answers  






Hi Could someone please provide Siebel Testing Interview questions for 5 years exp.

0 Answers  


Difference between the stress and load testing?

3 Answers  


What do you mean by Sanity Testing?

2 Answers   Keane India Ltd,


Please Tell me About Fish-Bone Model. Thanks in Adv.

0 Answers  


what is Adittrail in test factors

1 Answers  


What kind of testing to be done in client server apllication and web application? Explain....

2 Answers  


If there are so many settings/options to choose, how to write test cases?

1 Answers  


Categories