#include<bitset> #include<iostream> #include<queue> using namespace std; int main() { char answer; bitset<26> charset; bitset<26> repeat; char a[]={'s','a','s','a','b','v','s','a'}; #ifdef TEST gets(a); #endif int i; for(i=0;a[i]!='\0';i++){ if(charset.test(a[i]-'a')) { repeat.set(a[i]-'a'); }
charset.set(a[i]-'a'); } for(int j=0;j<i;j++) { if(!repeat.test(a[j]-'a')){ cout<<a[j]<<endl; return 0; } } cerr<<"No non repeating Character"<<endl; return 0; On Sun, Sep 11, 2011 at 9:16 PM, Kamakshii Aggarwal <kamakshi...@gmail.com>wrote: > @neha:can u pls explain ur method? > > > On Sun, Sep 11, 2011 at 9:09 PM, sukran dhawan <sukrandha...@gmail.com>wrote: > >> ya +1 to neha use bitset concept in c++ >> >> >> On Sun, Sep 11, 2011 at 8:24 PM, Neha Singh >> <neha.ndelhi.1...@gmail.com>wrote: >> >>> for ques 1 use bit manipulation >>> its more efficient >>> >>> -- >>> 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. >>> >> >> -- >> 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, > Kamakshi > kamakshi...@gmail.com > > -- > 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. > -- 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.