Re: [algogeeks] Re: FINDSR in spoj

2010-12-21 Thread Algoose chase
Brute force : Have 2 pointers one pointing to last character and other pointing to the first occurrence of last character. compare the chars at the corresponding positions and decrement both pointers. when the latter hits -1 increment the counter and reset it to its original value. if the compariso

Re: [algogeeks] Re: FINDSR in spoj

2010-12-06 Thread bharath kannan
I tried solving that prob..here's my code #include #include using namespace std; main() { string s; cin>>s; while(1) { if(s.size()==1 && s[0]=='*') break; int length=1,curr=0,start=0,count=1; for(int i=1;i>s; } } I am getting WA..anyone pls tel a testcase where the above

[algogeeks] Re: FINDSR in spoj

2010-12-06 Thread alexsolo
http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeek