one solution could be:

#include<stdio.h>
#include<string.h>
char non_repetition(char *p,int size)
{
    int i,j,flag=0;
    for(i=0;i<size;i++)
    {
        for(j=0;j<size;j++)
        {
            if(j==i)
                continue;
            if(p[i]==p[j])
                flag=1;
        }
        if(flag==0)
            return p[i];
        else
            flag=0;
    }
    return '\0';
}

int main()
{
    char
str[]="aaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccc
*V*cccccccccccccccccccccccc";
    int len=strlen(str);
    char firstNR=non_repetition(str,len);
    if(firstNR=='\0')
        printf("all are repeating at least once\n");
    else
        printf("first non repeated character is=%c\n",firstNR);
    return 0;
}

gives *V* as the output
On Mon, Jul 18, 2011 at 6:45 PM, Dumanshu <duman...@gmail.com> wrote:

> You are given a long string and you have to print the "first" non
> repeating character.
> Solve it keeping SC and TC in mind. That is present both solutions,
> one with high SC and low TC and viceversa.
>
> --
> 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.
>
>


-- 
  best wishes!!
    Vaibhav
    DU-MCA

-- 
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.

Reply via email to