@ross: ya, don't know what i was thinking.!! On Wed, Jun 22, 2011 at 2:33 PM, ross <jagadish1...@gmail.com> wrote:
> @Harshal, > Even if you use a buffer of size 256 it is still O(1), because 256 is > a constant invariant of n... > Ur solution is correct! > > > On Jun 22, 10:24 am, Harshal <hc4...@gmail.com> wrote: > > ignore above solution. My bad, did'nt see O(1) space constraint!! > > > > > > > > > > > > > > > > > > > > On Wed, Jun 22, 2011 at 10:53 AM, Harshal <hc4...@gmail.com> wrote: > > > You can make use of an auxiliary array(initialized to 0) to store the > count > > > of each char and then print it that many times. > > > char inp[]="abcdaabcdefe"; > > > int buff[256]={0}; > > > > > for(int i=0;i<strlen(inp);i++) > > > buff[inp[i]]++; > > > > > for(int j=0;j<256;j++) > > > while(buff[j]--) cout<<(char)j; > > > > > On Wed, Jun 22, 2011 at 10:27 AM, Sriganesh Krishnan < > 2448...@gmail.com>wrote: > > > > >> Input will be a string. We need to o/p a string with the order of > > >> characters same as the input but with same characters grouped > together. > > >> I/P: abcdacde > > >> O/P: aabccdde > > > > >> I/P: kapilrajadurga > > >> O/P: kaaaapilrrjdug > > > > >> I/P: 1232 > > >> O/P: 1223 ……………….. O(n) time……….. O(1) space……………. > > > > >> how can you approach these type of string related problems, is there > any > > >> specific technique involved? > > > > >> -- > > >> 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. > > > > > -- > > > Harshal Choudhary, > > > Final Year B.Tech CSE, > > > NIT Surathkal, Karnataka, India. > > > > -- > > Harshal Choudhary, > > Final Year B.Tech CSE, > > NIT Surathkal, Karnataka, India. > > -- > 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. > > -- Harshal Choudhary, Final Year B.Tech CSE, NIT Surathkal, Karnataka, India. -- 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.