Popoyee
BAN USERTraverse that tree in in-order and pre-order. you will have two arrays one for in-order traversal and one for pre-order traversal. You can recreate the same tree again from these two arrays. You can also have post-order instead of pre-order. But in-order it must. you cannot recreate from pre-order and post-order traversal.
- Popoyee August 11, 2013csenasa, you are correct. I have corrected it below.
bool HasPalindrome(char *str)
{
int n = strlen(str);
for(int i=1; i < n - 1; i++)
{
if( i < n - 2 && str[i] == str[i+1] && str[i-1] == str[i+2])
return true;
if(str[i-1] == str[i+1])
return true;
}
return false;
}
When input string is "madam"
when i will be 2
str[i] will be 'd', it will go in 2nd if and str[i-1] will be equal to str[i+1] so it will return true.
Can you please explain more about Rope please.
- Popoyee August 11, 2013