hey the above case wont work for a few cases....for instance wen the seventh letter of the alphabet is involved...
On 26 July 2011 15:32, sachet <sache...@gmail.com> wrote: > please explain....the code > #include<string> > using namespace std; > int main() > { > int x=0; > string str; > cin>>str;//only lowercase > for(int i=0;i<str.size();i++) x^=(1<<(str[i]-97)); > if(str.size()&1) > { if(!(x&(x-1)))cout<<"Palindrome\n"; > else cout<<"Not palindrome\n"; > } > > else > { if(!x)cout<<"Palindrome\n"; > else cout<<"Not palindrome\n"; > } > } > i could not understand the algo > > > On Jul 26, 11:07 am, Anika Jain <anika.jai...@gmail.com> wrote: > > int palin(char *p) > > { > > int x=0; > > while(*p) > > { > > x^=1<<(*p-'a'); > > p++; > > } > > int i=0,count=0; > > while(i<26) > > { > > count+=(1<<i & x)>>i; > > i++; > > } > > if(count>1) > > return 0; > > else > > return 1; > > > > > > > > > > > > > > > > } > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- regards Pratima :) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.