@Jalaj

if u consider only Space complexity then it can be done in O(n^2) time
and constant space

here i assume string u taken only hv a-z character nothing else

try this

for(i=0;i<length;i++){
         if( ! (st[i]>='a' && st[i]<='z') )
                 continue;

         count=1;

         for(j=i+1;j<length;j++){
                 if(st[j]==st[i]){
                       count++;
                       st[j]+=30;
                  }
         }

         cout<<st[i]<<count;
}








On May 17, 2:46 pm, kaushik sur <kaushik....@gmail.com> wrote:
> Hi Friends
>
> Hash Map takes 2byte [in Java] for holding a character
>
> So in Amazon -
> It takes A - 1
> M - 1
> Z - 1
> O - 1
> N - 1
>
> But it's time effective!
>
> Yes it takes additional space for intergers, for each key 4 byte for an
> integer!!! :-(
>
>     ***********
>
>  public void checkTheFrequency() {
>         for (int i = 0; i < str.length(); i++) {
>             char key = str.charAt(i);
>
>             if (checkMap.containsKey(key)!=
> false) {
>                 int value = checkMap.get(key);
>                 checkMap.put(key, ++value);
>             } else {
>                 checkMap.put(key, 1);
>             }
>         }
>
> *****************
> Best Regards
> Kaushik
>
> --
> 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 
> 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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to