Write an algorithm to find an palindrome

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

what is test case management?explain in brief.

1523


hi, this is geetha, i have one doubt regarding the vulnerability testing. For sql injection testing is there any need for the tools to be installed. If it is what is tool and what is the method to test in sql injection testing. Plz Guide me

1587


name poneno dept sun 9894433467 computer This is the xls sheet a programs written to transfer this data into database write test cases and test scenario?

1910


What is a defect?

643


a newly launched web site is hosted on web server.It is expected that 100 people visit the website every hour and browse 30 pages spending a total 15 minutes. what is the maximum hits/sec that the web server should support this load?justify your answer. need urgently. by rimesh

1398






if yahoo ceo asks you to do performance testing for yahoo site, what are the inputs you ask from them?

1607


wat are the questions would the project leader ask about the project?? please do send the answers early.

6523


Presently working in software company as a software test engineer with 1.5 yrs of experience but i am 2002 passout.Gap is 6 yrs.Is there any problem getting job in MNC? Which criteria HR follows for recruiting test engineer?

1600


What are the bugs we cannot find in black box?

678


What is showstopper defect?

661


What about manual testing opening in bangalore in September. Not getting a single interview call from last one month.

1563


Write all combinations of test cases for calculater on + symbel

1791


How will you prepare traceability matrix if there is no Business Doc and Functional Doc?

1782


what is the difference between test case and result matrix

1675


what is the most critical bug u have to find in ur project.My application is ERP based,in this purchase module is there.plz tell me the answer?

2175