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 difference between testing Techniques and tools? Give examples

1 Answers   Crea,


WHAT IS SECURITY TESTING.HOW TO DO SECURITY TESTING.IS THERE ANY FRAMEWORK AVAILABLE

2 Answers  


How to Test Web Application Without a Formal Test Plan....?

1 Answers   Infosys,


What is the difference between test case, test suite, test script, test scenario & test plan?

5 Answers   iSoft, McDonalds,


Big Bang Model isn't preferable for higher cost project? a. True b. False (Need the answer urgently) Thanks!

2 Answers  






wat is perpose of TRM ?(Test responsibility Matrix)

4 Answers   Synergy,


Hi friends I am kranti completed my IT diploma in 2005 & after that complete my software testing course. Now I am working in small software form as software tester. I have 2 + year experience in manual testing. Now I wan to change company. Plz told me is there any effect that I can not have any degree although I have 2 + experience ?

0 Answers  


Hi Please tell me about ERP for hr module what all function u found in hr model .

1 Answers  


what is v-model.why you are using v-model?& v-model follow parallelly approach is it correct?

2 Answers   Accenture,


If you're given a program that will average student grades, what kinds of inputs would you use?

0 Answers  


How did you go about testing a project?

2 Answers   HCL,


1. what is a difference between test plan and test strategy?2.What is the test plan is different from the test strategy? then how?

2 Answers  


Categories