@ALL, Here order of the string is preserved, if we use hash or bst, how you preserve the string order ?. Do you search again for each char ?
@jalaj, do we need to give importance to order or not ? amazon = > a2m1z1o1n1 Thanks, Sathaiah On Sun, May 16, 2010 at 5:40 PM, sharad kumar <aryansmit3...@gmail.com>wrote: > @Modelling expert. > > #include<iostream> > #include<map> > #include<string> > using namespace std; > int main() > { > string s="amazon"; > int i=0,j=0; > map<char,int>mp; > for(i=0;i<s.length();++i) > { > mp[s.at(i)]++; > } > for(i=0;i<s.length();++i) > { > cout<<s.at(i)<<mp[s.at(i)]; > } > cin.sync(); > cin.get(); > return 0; > } > PS.r u from Institute of mathematical Research science or CMI ....... > > > > > > > > > > > > > > > > > > > > > > > > > On Sun, May 16, 2010 at 1:50 PM, Modeling Expert < > cs.modelingexp...@gmail.com> wrote: > >> @sharad : Can you explain with same 'amazon' example for key mapping. >> if we have O(K) hash map, how would we map keys as We need to >> 'remember' mapping to print things back . >> e.g. ASCII valueof (C1)% sizeof(string) could be equal to >> valueof(C2)%sizeof(string) where strins is "C1C2..." >> >> @divya your solution looks OK to me , its would be O(k) for space, >> time O ( KlgK) , right ? >> >> On May 14, 8:20 am, sharad kumar <aryansmit3...@gmail.com> wrote: >> > cant u use a hash map ???? of O(K) where K is distinct elements in >> > string...... >> > >> > On Thu, May 13, 2010 at 8:13 PM, jalaj jaiswal < >> jalaj.jaiswa...@gmail.com>wrote: >> > >> > >> > >> > > input a character array from the user and output in the following way. >> > > example string is amazon.. then output should be a2m1z1o1n1 >> > >> > > i did it taking a 26 size array... some better solution ?? >> > >> > > -- >> > > With Regards, >> > > Jalaj Jaiswal >> > > +919026283397 >> > > B.TECH IT >> > > IIIT ALLAHABAD >> > >> > > -- >> > > 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 >> > > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> >> <algogeeks%2bunsubscr...@googlegroups.com<algogeeks%252bunsubscr...@googlegroups.com> >> > >> > > . >> > > For more options, visit this group at >> > >http://groups.google.com/group/algogeeks?hl=en. >> > >> > -- >> > yezhu malai vaasa venkataramana Govinda Govinda >> > >> > -- >> > 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 >> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> >> . >> > For more options, visit this group athttp:// >> 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 algoge...@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > > > -- > yezhu malai vaasa venkataramana Govinda Govinda > > -- > 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 > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@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 algoge...@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.