suppose the array is given as :
1 2 6 6 2 4
make the array as -1 -2 6 -6 2 -4.

working code ::

#include<stdio.h>

int main ()
{
        int a[] = {1 ,2 ,6 ,6,2,4,8,8};
        int i,j;
        for(i = 0; i < 8; i++)
        {
                j = a[i];
                if(a[i] < 0 )
                        j = -j;
                j--;
                if(a[j] > 0)
                        a[j] = -a[j];
        }
        for(i = 0; i < 8; i++)
                if(a[i] > 0)
                        printf("%d ",i+1);
        return 0;
}

correct me if i am wrong;

On Mon, Aug 1, 2011 at 6:55 PM, Deepak <[email protected]> wrote:

> Given an array of elements 'n'. some k<n elements are replaced by
> elements such that the repalced elements are <n. with o(n) find the
> missing elements, without wasting any extra memory.
>
> --
> 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.
>
>


-- 
Varun Pahwa
B.Tech (IT)
7th Sem.
Indian Institute of Information Technology Allahabad.
Ph : 09793899112
Official Email :: [email protected]
Another Email :: [email protected]

People who fail to plan are those who plan to fail.

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