Cisco Systems Interview Question
368 Interview Reviews |
Back to all Cisco Systems Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Engineer I at Cisco Systems:
How would you check if a string is a palindrome recursively?
| Tags: | technical, java, programming, c++ See more , See less 8 |
See more for this Cisco Systems Software Engineer I Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (3)
1 of 1 people found this helpful
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
bool check(char* arr, int front, int back)
{
printf("front [%d, %c], back[%d, %c]\n", front, arr[front], back, arr[back]);
if (front < back)
{
if (tolower(arr[front]) == tolower(arr[back]))
{
return check(arr, ++front, --back);
}
else
{
return false;
}
}
else
{
return true;
}
}
int main(int argc, char**argv)
{
if (2 != argc)
{
printf("provide input string to test\n");
exit(1);
}
printf ("Is %s a palindrome? %s\n",
argv[1],
check(argv[1], 0, strlen(argv[1]) - 1) ? "yes" : "no");
}
Helpful Answer?
Yes |
No
Inappropriate?
(if (<= (count w) 1)
#t
(if (eq? (first w) (last w))
(palindrome (bl (bf w)))
#f)))
;
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up



2 of 2 people found this helpful
by Interview Candidate:
if(String=="")return true;
if(String[0]==String[String.size()]){
IsPalindrome(String.substr(1,String.size()-2));
}else{
return false;
}