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 a defect and a failure?

0 Answers  


What is the Myers Boundary Table?

0 Answers  


What is Functinal Equivalent Test?

2 Answers   Valtech,


Test case's for a window having 4 button's addition, subdtraction, multiplication,division of two numbers having two no range(0,10000) and result box having range between (100,100000).

1 Answers   ABC,


Who will excatly assign the priority to the bug.. ...

5 Answers  






what is a bad defect and why do we write bad defects?

3 Answers  


Integraton testing

6 Answers   Infosys,


This question has been asked in my recent inerview with Adithya Birla Group.When to prepare System test plan after getting build or before getting build?

1 Answers   Aditya Birla,


What is the difference between Shakeout, Smoke, and Sanity Testing.

5 Answers  


What is the general testing process?

6 Answers   Polaris,


What are the different Testing methodologies?

7 Answers   IBM,


what are the things we consider when perform the UI testing of any web application please suggest me with basic things?

1 Answers  


Categories