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

When they freez(baseline) the requirement means in which phase of sdlc

5 Answers  


what is migration testing?

1 Answers   Cap Gemini, HCL,


what is application state, base state, & call state.

1 Answers   TCS,


How do u ensure that there are no duplicate testcases?

3 Answers  


how to Link the requirement with Test Cases in the Treaceability Matrix. Give real time Example ( Pl. Real Time Project testers only)

3 Answers  






eqivalance testing class is made from data and this is made to minimize the test cases and it is black box testing what at which particular time we do this testing i guess while creating test cases we consider this testing .plz if lett me know if i am wrong

1 Answers  


how to track defects by using JIRA bug tracking tool

2 Answers   HCL,


write the negative test cases for pencil based on it's functionality

2 Answers   TCS,


what is meant by CLOUD?

1 Answers   Bank of Baroda,


when doing regression testing, how can we know that other screen or module are affected?

4 Answers   Aspire,


How can u know IP Address of a computer?

2 Answers   HCL,


what is WinRunner frame

1 Answers   Exalt,


Categories