@Saurabh: Doesn't your code turn 123 into 321? Try this:

int function(int n)
{
    int a[10]={0};
    int result=0;
    int place=1;
    while(n){
        if(a[n%10]==0){
            a[n%10]=1;
            result+=(n%10)*place;
            place*=10;
        }
    n/=10;
    }
    return result;
}


Dave

On Sep 21, 3:12 pm, saurabh agrawal <[email protected]> wrote:
> int function(int n){
>
> int a[10]={0};
> int result =0;
> while(n){
>     if(a[n%10]==0){
>         a[n%10]=1;
>         result=10*result+n%10;
>     }
>     n/=10;}
>
> return result;`
>
>
>
> }
> On Wed, Sep 22, 2010 at 12:39 AM, Albert <[email protected]> wrote:
> > Given a number find the number by eliminating the duplicate digits in
> > the number..
>
> > for eg:   24526  ans is 2456
> > .....
>
> > int function(int n)
> > {
>
> >  .
> >  .
> >  .
>
> > }
>
> > Give all sort of solutions to this problem.....
>
> > Efficiency in the code is important ....
>
> > --
> > 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%2bunsubscr...@googlegroups­.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
>
> - Show quoted text -

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

Reply via email to