Click here to Skip to main content
15,913,570 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi

input array is

var array = [1,2,3,2];

i want a output like

output = [1,3]
Posted
Comments
Peter Leow 27-Dec-13 5:29am    
What have you tried?
Member 10488806 27-Dec-13 7:01am    
i found solution

Hi,

You could find these
link [^]
link[^] helpful.
Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
v2
C#
here is my solution

function eliminateDuplicates(arr) {
        var i,
        len = arr.length,
        out = [],
        obj = {};

        for (i = 0; i < len; i++) {
            if (obj[arr[i]] != 0 && arr[i] != undefined)
                obj[arr[i]] = 0;
            else
                delete obj[arr[i]];
        }
        for (i in obj) {
            out.push(i);
        }
        return out;
    }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900