use binary tree and insert in it every character u come across. if the character is already present then increment its count. use this approach if u r nt sure that characters will be only 26 or no. if u r sure there r 26 char then u cn use hash.. plz correct me if i m wrong. thanks
On 14 May 2010 08:50, sharad kumar <[email protected]> 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 > <[email protected]>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 [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<algogeeks%[email protected]> >> . >> 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]<algogeeks%[email protected]> > . > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
